Re: When are index scans used over seq scans? - Mailing list pgsql-performance

From Richard van den Berg
Subject Re: When are index scans used over seq scans?
Date
Msg-id 4267612C.10803@trust-factory.com
Whole thread Raw
In response to Re: When are index scans used over seq scans?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: When are index scans used over seq scans?
List pgsql-performance
Tom Lane wrote:
> The explain shows no such thing.  What is the *actual* runtime of
> each plan per EXPLAIN ANALYZE, please?

Ok, it took 3.5 hours to complete. :-/

This is with the default cpu_tuple_cost = 0.01:

 Nested Loop  (cost=252.80..233010147.16 rows=1035480320 width=98)
(actual time=0.369..12672213.137 rows=6171334 loops=1)
   Join Filter: (("outer".starttimetrunc <= "inner".ts) AND
("outer".finishtimetrunc >= "inner".ts))
   ->  Seq Scan on sessions us  (cost=0.00..26822.36 rows=924536
width=106) (actual time=0.039..5447.349 rows=924536 loops=1)
   ->  Materialize  (cost=252.80..353.60 rows=10080 width=8) (actual
time=0.000..2.770 rows=10080 loops=924536)
         ->  Seq Scan on duration du  (cost=0.00..252.80 rows=10080
width=8) (actual time=0.019..13.397 rows=10080 loops=1)
 Total runtime: 12674486.670 ms

Once again with cpu_tuple_cost = 0.1:

 Nested Loop  (cost=0.00..667684584.42 rows=1035480320 width=98) (actual
time=42.892..39877.928 rows=6171334 loops=1)
   ->  Seq Scan on sessions us  (cost=0.00..110030.60 rows=924536
width=106) (actual time=0.020..917.803 rows=924536 loops=1)
   ->  Index Scan using ix_du_ts on duration du  (cost=0.00..604.46
rows=1120 width=8) (actual time=0.004..0.011 rows=7 loops=924536)
         Index Cond: (("outer".starttimetrunc <= du.ts) AND
("outer".finishtimetrunc >= du.ts))
 Total runtime: 41635.468 ms
(5 rows)

--
Richard van den Berg, CISSP
-------------------------------------------
Trust Factory B.V. |     www.dna-portal.net
Bazarstraat 44a    |  www.trust-factory.com
2518AK The Hague   |  Phone: +31 70 3620684
The Netherlands    |  Fax  : +31 70 3603009
-------------------------------------------

pgsql-performance by date:

Previous
From: William Yu
Date:
Subject: Re: How to improve db performance with $7K?
Next
From: "David Roussel"
Date:
Subject: How can an index be larger than a table