Search Postgresql Archives

Re: Yet Another COUNT(*)...WHERE...question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Yes, optimization. :)  You don't need an exact count to tell someone
> that there's more data and they can go to it.


In general, I agree. But my example of Amazon was only to illustrate
the point about two queries and why they may be needed. I seem to see
many more pages than you do, but in any case, Google and Amazon can
afford to be less precise.

Thanks for the suggestion of using EXPLAIN and parsing an
approximation, but when you need to show a trader how many trades he
has made, for instance, then approximation is not a possibility at
all. Especially not if the numbers sway so wildly --


FIRSTDB=# explain select * from trades where t_id = 'kXjha';
                                    QUERY PLAN
-----------------------------------------------------------------------------------
 Bitmap Heap Scan on trades (cost=15.77..1447.12 rows=374 width=224)
   Recheck Cond: ((t_id)::text = 'kXjha'::text)
   ->  Bitmap Index Scan on trades_tid_date  (cost=0.00..15.67 rows=374 width=0)
         Index Cond: ((t_id)::text = 'kXjha'::text)
(4 rows)

FIRSTDB=# select count(*) from trades where t_id = 'kXjha';
 count
-------
  3891
(1 row)



Could I do something so that the EXPLAIN showed up with slightly more
close-to-accurate stats? The above query is just after a "vacuum
analyze"!

Much appreciate the suggestions.

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux