Subject Re: [firebird-support] PK vs Index on table scan
Author Martijn Tonies
> > Can you show us the full table DDL?
>
> CREATE TABLE CUSTOMERS
> (
> LINK VARCHAR( 10) NOT NULL COLLATE NONE,
> DELETED CHAR( 1) COLLATE NONE,
> TELEPHONE VARCHAR( 15) COLLATE NONE,
> CEL VARCHAR( 12) COLLATE NONE,
> SURNAME VARCHAR( 36) COLLATE NONE,
> "NAME" VARCHAR( 36) COLLATE NONE,
> ADDRESS1 VARCHAR( 36) COLLATE NONE,
> ADDRESS2 VARCHAR( 36) COLLATE NONE,
> ADDRESS3 VARCHAR( 36) COLLATE NONE,
> ADDRESS4 VARCHAR( 36) COLLATE NONE,
> SUBURBLINK VARCHAR( 10) COLLATE NONE,
> ORDERS FLOAT,
> LASTORDERDATE DATE,
> LASTORDERTIME TIME,
> LASTORDERLINK VARCHAR( 10) COLLATE NONE,
> SPENT NUMERIC( 15, 2),
> CREDITCARD VARCHAR( 24) COLLATE NONE,
> CVC CHAR( 3) COLLATE NONE,
> EXPDATE VARCHAR( 5) COLLATE NONE,
> TELVALID FLOAT,
> BIRTHDATE DATE,
> ADDDATE DATE,
> ADDUSER VARCHAR( 10) COLLATE NONE,
> EMAIL VARCHAR( 40) COLLATE NONE,
> WEBPASSWORD VARCHAR( 15) COLLATE NONE,
> RANKING FLOAT,
> MTD NUMERIC( 15, 2),
> MONTHORDERS FLOAT,
> IDNUMBER VARCHAR( 15) COLLATE NONE,
> COMPANY CHAR( 1) COLLATE NONE,
> DNOTES_ENABLED CHAR( 1) COLLATE NONE,
> DNOTES_TOTAL NUMERIC( 15, 2),
> DNOTES_VOUCHER VARCHAR( 16) COLLATE NONE,
> DNOTES_USER VARCHAR( 10) COLLATE NONE,
> DNOTES_SINCE DATE,
> REMARKS VARCHAR( 450) COLLATE NONE,
> INHOUSE VARCHAR( 450) COLLATE NONE,
> LASTUPDT DATE,
> CONSTRAINT CUSTOMERS_PRIMARY PRIMARY KEY (LINK)
> );
>
> CREATE DESC INDEX I_CUSTOMERS_SPENT ON CUSTOMERS (SPENT);
> CREATE ASC INDEX I_CUSTOMERS_SUBURBLINK ON CUSTOMERS (SUBURBLINK);
> CREATE ASC INDEX INDEX_CEL ON CUSTOMERS (CEL);
> CREATE ASC INDEX INDEX_SURNAME ON CUSTOMERS (SURNAME);
> CREATE ASC INDEX INDEX_TELEPHONE ON CUSTOMERS (TELEPHONE);
>
> table has 12123 rows
>
> Martin,
> it does this on all of my tables when I do a search on the PK
> I use firebird 1.5.2
> I have done a full backup and restore with no changes
> If I create an additional index on customers(link) everything works as
> expected ie. 1 indexed read with plan INDEX (I_CUSTOMERS_LINK)

Perhaps the indices for the PKs are inactive. Can you try re-activating it?

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com