dynamic-static date once again - Mailing list pgsql-bugs

From Tomasz Myrta
Subject dynamic-static date once again
Date
Msg-id 3BA1228A.948C3F25@lamer.pl
Whole thread Raw
In response to dynamic-static date  (Tomasz Myrta <jasiek@lamer.pl>)
Responses Re: dynamic-static date once again  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane wrote:
>
> Tomasz Myrta <jasiek@lamer.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

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: plpgsql & temp table -bug
Next
From: Tom Lane
Date:
Subject: Re: PQexec infinite loop