pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedStuck using Sequential Scan
2+ messages / 2 participants
[nested] [flat]
* Stuck using Sequential Scan
@ 2004-09-07 21:32 Jeremy M. Guthrie <jeremy.guthrie@berbee.com>
2004-09-11 06:07 ` Re: Stuck using Sequential Scan Oliver Elphick <olly@lfix.co.uk>
0 siblings, 1 reply; 2+ messages in thread
From: Jeremy M. Guthrie @ 2004-09-07 21:32 UTC (permalink / raw)
To: pgsql-performance
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have a problem where I have the table format listed below. I have the
primary key tsyslog_id and the index built against it. However, when I
select a unique row, it will only ever do a seq scan even after I turn off
all other types except indexscan. I understand you cannot fully turn off seq
scan.
Syslog_TArchive size: 1,426,472,960 bytes
syslog_tarchive_pkey size: 132,833,280 bytes
archhost_idx size: 300,802,048 bytes
tarchdatetime_idx size: 159,293,440 bytes
tarchhostid_idx size: 362,323,968 bytes
I cannot run vacuum more than once a day because of its heavy IO penalty. I
run analyze once an hour. However, if I run analyze then explain, I see no
difference in the planners decisions. What am I missing?
TSyslog=# \d syslog_tarchive;
Table "public.syslog_tarchive"
Column | Type |
Modifiers
- ------------+------------------------+-------------------------------------------------------------------------
tsyslog_id | bigint | not null default
nextval('public.syslog_tarchive_tsyslog_id_seq'::text)
facility | integer |
severity | integer |
date | date |
time | time without time zone |
host | character varying(128) |
message | text |
Indexes:
"syslog_tarchive_pkey" primary key, btree (tsyslog_id)
"archhost_idx" btree (host)
"tarchdatetime_idx" btree (date, "time")
"tarchhostid_idx" btree (tsyslog_id, host)
TSyslog=# explain select * from tsyslog where tsyslog_id=431650835;
QUERY PLAN
- -------------------------------------------------------------------------
Seq Scan on tsyslog (cost=100000000.00..100000058.20 rows=2 width=187)
Filter: (tsyslog_id = 431650835)
(2 rows)
- --
- --------------------------------------------------
Jeremy M. Guthrie jeremy.guthrie@berbee.com
Senior Network Engineer Phone: 608-298-1061
Berbee Fax: 608-288-3007
5520 Research Park Drive NOC: 608-298-1102
Madison, WI 53711
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBPijTqtjaBHGZBeURAndgAJ4rT2NpG9aGAdogoZaV+BvUfF6TjACfaexf
LrBzhDQK72u8dCUuPOSHB+Y=
=DSxi
-----END PGP SIGNATURE-----
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Stuck using Sequential Scan
2004-09-07 21:32 Stuck using Sequential Scan Jeremy M. Guthrie <jeremy.guthrie@berbee.com>
@ 2004-09-11 06:07 ` Oliver Elphick <olly@lfix.co.uk>
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Elphick @ 2004-09-11 06:07 UTC (permalink / raw)
To: jeremy.guthrie@berbee.com; +Cc: pgsql-performance
On Tue, 2004-09-07 at 22:32, Jeremy M. Guthrie wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I have a problem where I have the table format listed below. I have the
> primary key tsyslog_id and the index built against it. However, when I
> select a unique row, it will only ever do a seq scan even after I turn off
> all other types except indexscan. I understand you cannot fully turn off seq
> scan.
...
> I cannot run vacuum more than once a day because of its heavy IO penalty. I
> run analyze once an hour. However, if I run analyze then explain, I see no
> difference in the planners decisions. What am I missing?
>
>
> TSyslog=# \d syslog_tarchive;
> Table "public.syslog_tarchive"
> Column | Type |
> Modifiers
> - ------------+------------------------+-------------------------------------------------------------------------
> tsyslog_id | bigint | not null default
...
>
> TSyslog=# explain select * from tsyslog where tsyslog_id=431650835;
That constant is INTEGER, whereas the column is BIGINT; there is no
automatic conversion in this case, so the planner does not realise the
index is usable for this query (I think 8.0 solves this).
Try: select * from tsyslog where tsyslog_id=431650835::BIGINT;
--
Oliver Elphick olly@lfix.co.uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"I am crucified with Christ; nevertheless I live; yet
not I, but Christ liveth in me; and the life which I
now live in the flesh I live by the faith of the Son
of God, who loved me, and gave himself for me."
Galatians 2:20
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-09-11 06:07 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-09-07 21:32 Stuck using Sequential Scan Jeremy M. Guthrie <jeremy.guthrie@berbee.com>
2004-09-11 06:07 ` Oliver Elphick <olly@lfix.co.uk>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox