All pastes #16425 Raw Edit

Anonymous

public text v1 · immutable
#16425 ·published 2005-06-29 22:38 UTC
rendered paste body

# PREPARE checkval(int,text) AS SELECT id,val from values where status=$1 and val=$2 order by id desc LIMIT 1;

# EXPLAIN SELECT id,val from values where status=1 and val='00000000' order by id desc limit 1;
                                                  QUERY PLAN
---------------------------------------------------------------------------------------------------------------
 Limit  (cost=0.00..25.66 rows=1 width=138)
   ->  Index Scan Backward using values_pkey on values  (cost=0.00..1046955.27 rows=40794 width=138)
         Filter: ((status = 1) AND ((val)::text = '00000000'::text))
(3 rows)



# EXPLAIN EXECUTE checkval(1,'00000000');
                                                QUERY PLAN
----------------------------------------------------------------------------------------------------------
 Limit  (cost=554.62..554.63 rows=1 width=71)
   ->  Sort  (cost=554.62..554.68 rows=23 width=71)
         Sort Key: id
         ->  Index Scan using values_val_idx on values  (cost=0.00..554.10 rows=23 width=71)
               Index Cond: ((val)::text = $2)
               Filter: (status = $1)
(6 rows)