From: | "sathiya psql" <sathiya(dot)psql(at)gmail(dot)com> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Cc: | "Mark Mielke" <mark(at)mark(dot)mielke(dot)cc>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: count * performance issue |
Date: | 2008-03-06 06:43:17 |
Message-ID: | f966c2ee0803052243w723e2866gbfc37128620d1c6d@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
is there any way to explicitly force the postgres to use index scan
On Thu, Mar 6, 2008 at 12:06 PM, A. Kretschmer <
andreas(dot)kretschmer(at)schollglas(dot)com> wrote:
> am Thu, dem 06.03.2008, um 1:26:46 -0500 mailte Mark Mielke folgendes:
> >
> >
> > 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,
>
> No. The current index-implementation contains no information about the
> row-visibility within the current transaction. You need to scan the
> whole data-table to obtain if the current row are visible within the
> current transaction.
>
>
> > 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+? :-)
>
> right.
>
>
> Andreas
> --
> Andreas Kretschmer
> Kontakt: Heynitz: 035242/47150, D1: 0160/7141639 (mehr: -> Header)
> GnuPG-ID: 0x3FFF606C, privat 0x7F4584DA http://wwwkeys.de.pgp.net
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
>
> http://mail.postgresql.org/mj/mj_wwwusr?domain=postgresql.org&extra=pgsql-performance
>
From | Date | Subject | |
---|---|---|---|
Next Message | sathiya psql | 2008-03-06 06:48:25 | Fwd: count * performance issue |
Previous Message | A. Kretschmer | 2008-03-06 06:36:44 | Re: count * performance issue |