Subject | Re: [firebird-support] INDEX directionality, why and how? What about KEYs? |
---|---|
Author | Michael Ludwig |
Post date | 2010-05-25T19:57:40Z |
Michael Ludwig schrieb am 11.05.2010 um 18:10:42 (+0200):
http://tech.groups.yahoo.com/group/firebird-support/message/105190?o=0&var=1
Simple test script to show plans:
\,,,/
(o o)
------oOOo-(_)-oOOo------
create table ttpkix (id integer primary key, name varchar(10));
commit;
insert into ttpkix values (1, 'eins');
insert into ttpkix values (2, 'zwei');
insert into ttpkix values (3, 'drei');
commit;
set plan on;
select min(id) from ttpkix;
select max(id) from ttpkix;
create descending index tt_pk_desc on ttpkix(id);
commit;
select min(id) from ttpkix;
select max(id) from ttpkix;
-------------------------
--
Michael Ludwig
> Ann W. Harrison schrieb am 10.05.2010 um 20:38:10 (-0400):Answering my own question: Yes.
> > > Second point of interest, what kind of indexes and with what
> > > directionality are used to back up the following CONSTRAINTs:
> > >
> > > * PRIMARY KEY
> > > * FOREIGN KEY
> > > * UNIQUE
> >
> > Ascending
>
> So does the general advice of creating a DESCENDING INDEX for
> queries looking for high values apply here?
> Might it be worth while creating an additional DESCENDING INDEX in anyAlso yes. Just found it confirmed here:
> of these three cases?
http://tech.groups.yahoo.com/group/firebird-support/message/105190?o=0&var=1
Simple test script to show plans:
\,,,/
(o o)
------oOOo-(_)-oOOo------
create table ttpkix (id integer primary key, name varchar(10));
commit;
insert into ttpkix values (1, 'eins');
insert into ttpkix values (2, 'zwei');
insert into ttpkix values (3, 'drei');
commit;
set plan on;
select min(id) from ttpkix;
select max(id) from ttpkix;
create descending index tt_pk_desc on ttpkix(id);
commit;
select min(id) from ttpkix;
select max(id) from ttpkix;
-------------------------
--
Michael Ludwig