Re: Recheck condition - Mailing list pgsql-general

From Josh Harrison
Subject Re: Recheck condition
Date
Msg-id 8d89ea1d0711281120s462f66dfxec0d0af74ad91f02@mail.gmail.com
Whole thread Raw
In response to Recheck condition  ("Josh Harrison" <joshques@gmail.com>)
Responses Re: Recheck condition  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
>Some indexes are inexact, i.e. they may sometimes return tuples that
>don't actually match the index condition.

What causes an index to be inexact. When you create an index and vacuum it regularly, it is suppose to be correct....right??


>This also happens with bitmap
>scans, because it'll return anything in the bitmap which will probably
>be more than what you asked for. The recheck just means that the
>planner retests the index condition on the result to make sure you only
>get the rows you wanted

So does recheck condition affect the performance of the queries since it basically rechecks the condition?
Also does it goes to the heap to retest ?

For example for this query
explain analyze select count(*) from foo where foo_id=1 I get the following plan

QUERY PLAN                          
                                                                                            
 --------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=1949.84..1949.85 rows=1 width=0) (actual time=7.996..7.996 rows=1 loops=1)                                     
   ->  Bitmap Heap Scan on foo  (cost=277.45..1924.94 rows=9959 width=0) (actual time=1.903..5.270 rows=10020 loops=1)       
         Recheck Cond: (foo_id = 1::numeric)                                                                             
         ->  Bitmap Index Scan on foo_pk  (cost=0.00..274.96 rows=9959 width=0) (actual time=1.864..1.864 rows=10020 loops=1)
               Index Cond: (foo_id = 1::numeric)                                                                         
 Total runtime: 8.062 ms

Can you please explain to me with respect to this example what is happening here? This is a small table but for big tables the performance is not very good. Does recheck condition brings down the query performance?

Thanks
josh

pgsql-general by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: [HACKERS] plperl and regexps with accented characters - incompatible?
Next
From: "Cyril VELTER"
Date:
Subject: [Re] Re: [Re] Re: [Re] Re: Unknown winsock error 10061while dumping a big database