From: | Tomasz Myrta <jasiek(at)lamer(dot)pl> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | dynamic-static date once again |
Date: | 2001-09-13 21:18:02 |
Message-ID: | 3BA1228A.948C3F25@lamer.pl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Tom Lane wrote:
>
> Tomasz Myrta <jasiek(at)lamer(dot)pl> writes:
> > Why the first expression is 25 times slower?
>
> Hard to say, when you haven't shown us the schema. (Column datatypes,
> definitions of available indexes, etc are all critical information for
> this sort of question.)
OK
Don't panic with names, They are polish ;-)
1. TABLES
create table TRASY(
id_trasy integer not null PRIMARY KEY,
del date default '9999-12-31',
nazwa varchar (80)
);
create table KURSY(
id_kursu integer not null PRIMARY KEY,
id_trasy integer not null references TRASY,
data_kursu date not null,
limit_miejsc smallint not null
);
2. INDEXES
trasy | CREATE UNIQUE INDEX trasy_pkey ON trasy USING btree
(id_trasy int4_ops)
kursy | CREATE UNIQUE INDEX kursy_pkey ON kursy USING btree
(id_kursu int4_ops)
kursy | CREATE INDEX ind_kurs_ ON kursy USING btree (id_trasy
int4_ops, data_kursu date_ops)
3. TEST
This time kursy has less rows:
saik=# EXPLAIN SELECT * from kursy where id_trasy=1 and
saik-# data_kursu=date('2001-12-12');
NOTICE: QUERY PLAN:
Index Scan using ind_kurs_ on kursy (cost=0.00..8.19 rows=1 width=14)
EXPLAIN
saik=# EXPLAIN SELECT * from kursy where id_trasy=1
saik-# and data_kursu='2001-12-12';
NOTICE: QUERY PLAN:
Index Scan using ind_kurs_ on kursy (cost=0.00..2.02 rows=1 width=14)
I think that's all
Tomek
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-09-13 22:15:18 | Re: PQexec infinite loop |
Previous Message | Peter Eisentraut | 2001-09-13 18:12:17 | Re: plpgsql & temp table -bug |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2001-09-13 23:47:44 | Proposed installation dir change |
Previous Message | Haroldo Stenger | 2001-09-13 19:58:18 | Re: Need feedback: GeneXus will support PostgreSQL |