Article View: borland.public.interbase.sql
Article #680Contact Age Query
From: Jason Summers
Date: Fri, 02 Nov 2007 02:27
Date: Fri, 02 Nov 2007 02:27
23 lines
1814 bytes
1814 bytes
Hello Again,
I have a database of contacts, and each contact has a birthdate (CBIRTHDAY).
I'm using the following query to determine which contacts are at least X
years old.
select CONTACTID from CONTACTS where (('Now' - CBIRTHDAY) / 365) > [Age X]
Question is, if CBIRTHDAY is indexed, will the Interbase Optimizer be able
to utilize this index using this query? Since this is a calculation, I'm
not sure if it'd be smart enough to know.
Or if that query cannot be optimized how about this one?
select CONTACTID from CONTACTS where ('Now' - CBIRTHDAY) > ([Age X] * 365)
(assume [Age X] * 365 was precalculated and put into the query string)
If neither of these queries are going to run quickly, any recommendations on
what I could do to speed this up?
Thanks everyone,
- Jason
Technical Details
Message-ID:
<472a8b02$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,32d2d968e29f0f52,start X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Jason Summers" <jason@grinc.org> From: "Jason Summers" <jason@grinc.org> Newsgroups: borland.public.interbase.sql Subject: Contact Age Query Date: Thu, 1 Nov 2007 21:27:01 -0500 Lines: 24 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Windows Mail 6.0.6000.16480 X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545 NNTP-Posting-Host: 64.251.145.50 Message-ID: <472a8b02$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1193970434 64.251.145.50 (1 Nov 2007 19:27:14 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail