From: | Mark Mielke <mark(at)mark(dot)mielke(dot)cc> |
---|---|
To: | Shoaib Mir <shoaibmir(at)gmail(dot)com> |
Cc: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: count * performance issue |
Date: | 2008-03-06 06:26:46 |
Message-ID: | 47CF8EA6.8070503@mark.mielke.cc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
>
> There aren't a general solution. If you realy need the exact count of
> tuples than you can play with a TRIGGER and increase/decrease the
> tuple-count for this table in an extra table.
>
Of course, this means accepting the cost of obtaining update locks on
the count table.
The original poster should understand that they can either get a fast
estimated count, or they can get a slow accurate count (either slow in
terms of select using count(*) or slow in terms of updates using
triggers and locking).
Other systems have their own issues. An index scan may be faster than a
table scan for databases that can accurately determine counts using only
the index, but it's still a relatively slow operation, and people don't
normally need an accurate count for records in the range of 100,000+? :-)
Cheers,
mark
--
Mark Mielke <mark(at)mielke(dot)cc>
From | Date | Subject | |
---|---|---|---|
Next Message | sathiya psql | 2008-03-06 06:31:09 | Re: count * performance issue |
Previous Message | Shoaib Mir | 2008-03-06 06:26:07 | Re: count * performance issue |