🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Problem with index

#6
From: Cyber Sinh
Date: Tue, 19 Jul 2005 12:55
70 lines
2963 bytes
Hi,

Why the first query don't use index on T_TRACK (take 15 s!) whereas the 
second use it (and take only 0s!)?

PS: I use Firebird 1.5

SELECT t_album.c_id, t_album.c_artist, t_album.c_name
FROM t_album
INNER JOIN t_albumjoin ON t_albumjoin.c_album = t_album.c_id
INNER JOIN t_track ON t_albumjoin.c_track = t_track.c_id
INNER JOIN t_artist ON t_artist.c_id = t_track.c_artist
WHERE t_artist.c_name = 'Evanescence';


Plan
PLAN JOIN (T_TRACK NATURAL,T_ARTIST INDEX (ARTIST_PKEY),T_ALBUMJOIN 
INDEX (ALBUMJOIN_FK_TRACK),T_ALBUM INDEX (ALBUM_PKEY))

Plan Adpat�
PLAN JOIN (T_TRACK NATURAL,T_ARTIST INDEX (ARTIST_PKEY),T_ALBUMJOIN 
INDEX (ALBUMJOIN_FK_TRACK),T_ALBUM INDEX (ALBUM_PKEY))

------ Performance info ------
Prepare time = 0ms
Execute time = 15s 828ms
Avg fetch time = 565,29 ms
Current memory = 1 110 768
Max memory = 1 244 108
Memory buffers = 2 048
Reads from disk to cache = 3 680
Writes from cache to disk = 0
Fetches from cache = 5 112 579



SELECT t_album.c_id, t_album.c_artist, t_album.c_name
FROM t_album
INNER JOIN t_albumjoin ON t_albumjoin.c_album = t_album.c_id
INNER JOIN t_track ON t_albumjoin.c_track = t_track.c_id
INNER JOIN t_artist ON t_artist.c_id = t_track.c_artist
WHERE t_artist.c_name = 'Evanescence' AND
t_track.c_name = 'Anywhere' AND
t_album.c_name = 'Origin';


Plan
PLAN JOIN (T_TRACK INDEX (TRACK_NAME),T_ARTIST INDEX 
(ARTIST_PKEY),T_ALBUM INDEX (ALBUM_NAME),T_ALBUMJOIN INDEX 
(ALBUMJOIN_FK_TRACK,ALBUMJOIN_FK_ALBUM))

Plan Adpat�
PLAN JOIN (T_TRACK INDEX (TRACK_NAME),T_ARTIST INDEX 
(ARTIST_PKEY),T_ALBUM INDEX (ALBUM_NAME),T_ALBUMJOIN INDEX 
(ALBUMJOIN_FK_TRACK,ALBUMJOIN_FK_ALBUM))

------ Performance info ------
Prepare time = 0ms
Execute time = 0ms
Avg fetch time = 0,00 ms
Current memory = 1 128 940
Max memory = 1 244 108
Memory buffers = 2 048
Reads from disk to cache = 0
Writes from cache to disk = 0
Fetches from cache = 783


Thanks for your help...
Cyber Sinh
Technical Details
Message-ID: <42dcf727$0$1453$626a14ce@news.free.fr>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-1.proxad.net!news11-e.free.fr!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,d46142938748c3f7,start
X-Google-Thread: fd38c,d46142938748c3f7,start
X-Google-Attributes: gid114a0e,gidfd38c,public
X-Google-Language: ENGLISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!proxad.net!infeed-1.proxad.net!news11-e.free.fr!not-for-mail
Date: Tue, 19 Jul 2005 14:55:36 +0200
From: Cyber Sinh <cyber.sinh@-moins.ceci-free.fr>
User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)
X-Accept-Language: fr, en
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql,borland.public.interbase.general
Subject: Problem with index
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Lines: 70
Message-ID: <42dcf727$0$1453$626a14ce@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 19 Jul 2005 14:50:47 MEST
NNTP-Posting-Host: 82.65.174.67
X-Trace: 1121777447 news11-e.free.fr 1453 82.65.174.67:1711
X-Complaints-To: abuse@proxad.net