🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #408

Smart indexes

#408
From: Mikael
Date: Mon, 03 Mar 2008 10:00
57 lines
2887 bytes
IB 7.5.1

How to make smart indexes for this query?
My problem is that I whant good a index for the join itself and the criteria 
at the same time.

Mikael


Select
    Pot, Env, SessionID, LogId, SenderN, ReceiverN, Doctype
From
    Transferlog o
        inner join Documents d on (o.SessionID = d.SessionID and o.Env = 
d.Env and o.LogID = d.LogID)
Where
            o.Pot between '2008-01-08 09:02:48' and '2008-01-08 10:59:59'
     and o.Env = 'xib'
     and o.senderpi = 7
     and d.Docnr = '7815314'
     and d.Area = 'CIRCLE'
order by 1 Descending, 2 Descending, 3 Descending

CREATE TABLE DOCUMENTS (

    DOCIDENT    INTEGER NOT NULL,
    SESSIONID   INTEGER NOT NULL,
    ENV               VARCHAR(12) DEFAULT 'INIT' NOT NULL,
    LOGID           VARCHAR(20) NOT NULL,
    DOCNR         VARCHAR(35) NOT NULL,
    MSGFUNC    VARCHAR(35)
);

ALTER TABLE DOCUMENTS ADD CONSTRAINT PKDOC PRIMARY KEY (DOCIDENT);



CREATE TABLE TRANSFERLOG (
    LOGID                                          VARCHAR(20) NOT NULL,
    "EVENT"                                       SMALLINT NOT NULL,
    STATUS                                       SMALLINT NOT NULL,
    RESENT                                       CHAR(1) NOT NULL,
    STATUSDESCRIPTION             VARCHAR(150) NOT NULL,
    POT                                               TIMESTAMP NOT NULL,
    SESSIONID                                   INTEGER NOT NULL,
    ENV                                               VARCHAR(12) DEFAULT 
'INIT' NOT NULL,
    SENDERID                                    VARCHAR(35),
    SENDERN                                    VARCHAR(73),
    SENDERPI                                    INTEGER,
    RECEIVERID                                VARCHAR(35),
    RECEIVERN                                 VARCHAR(73),
    SENDERPI                                    INTEGER,
    ROWID                                         INTEGER NOT NULL
);

ALTER TABLE TRANSFERLOG ADD CONSTRAINT PKTL PRIMARY KEY (ROWID);
Technical Details
Message-ID: <47cbcc24@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,ae9de598b62dbfeb,start
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mikael" <mikael.nilsson@put.com>
Newsgroups: borland.public.interbase.sql
Subject: Smart indexes
Date: Mon, 3 Mar 2008 11:00:04 +0100
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
NNTP-Posting-Host: 85.119.132.236
Message-ID: <47cbcc24@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1204538404 85.119.132.236 (3 Mar 2008 02:00:04 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail