🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Too slow... can't think of a faster way.

#103
From: Frederic Gelinas
Date: Tue, 03 Jun 2008 14:07
26 lines
1675 bytes
Here is a quite simple query and it's plan.  It takes 25 to 30 seconds
to complete, which is way too long.  I can't think of another way of
doing it.

The table ARITEM has a lot of rows.  Each ARITEM row can have an
ARTRANSACTION tied to it (only 1.  There is an ARTRANSACTIONID field in
ARITEM).  I need all the ARITEM that have a scandate >= to a specified
date and that there is no ARTRANSACTION linked to it, or, if there is
an ARTRANSACTION, the date on the ARTransaction must be > the same date.

Here is how I did it:

Select sum(amount) from ARITEM a  left outer join ARTRANSACTION art on
art.ID=a.ARTRANSACTIONID
  where a.client=:aClient and a.customer=:aCustomer
  and ((a.SCANDATE <= :aDate)
  and (a.ARTRANSACTIONID is null or art.trandate > :aDate))

Plan:

PLAN JOIN (A INDEX (I_ARITEM_SCANDATE),ART INDEX (RDB$PRIMARY64))

I can't think of another way of doing this query, or speeding it.


-- 
Technical Details
Message-ID: <48455030@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,a4b1f4361f20c519,start
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Frederic Gelinas" <frederic_gelinas@hotmail.com>
Subject: Too slow... can't think of a faster way.
Newsgroups: borland.public.interbase.sql
User-Agent: XanaNews/1.18.1.6
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 74.12.225.203
Message-ID: <48455030@newsgroups.borland.com>
Date: 3 Jun 2008 07:07:44 -0700
X-Trace: newsgroups.borland.com 1212502064 74.12.225.203 (3 Jun 2008 07:07:44 -0700)
Lines: 27
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.germany.com!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail