🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Speed Difference

#511
From: asf
Date: Mon, 05 Nov 2007 17:04
29 lines
1728 bytes
The UNION should be faster because the OR clause in the first statement will 
prevent the use of an index on prefix.

Dan

"Jason Summers" <jason@grinc.org> wrote in message 
news:472bd113$1@newsgroups.borland.com...
> Hello Again,
>
> I'm curious as to the speed of the UNION statement.  I have a CONTACTS 
> table, which contains phone number prefix fields: HPHONEPREFIX, 
> MPHONEPREFIX, (and others, but we'll omit those for brevity).  These 
> fields are indexed.
>
> Comparing these two statements:  Say I want all people who have any phone 
> number with '573' prefix.
>
> select CONTACTID from CONTACTS where (HPHONEPREFIX = '573') OR 
> (MPHONEPREFIX = '573')
>
> As compared to this:
> select CONTACTID from CONTACTS where HPHONEPREFIX = '573'
> UNION
> select CONTACTID from CONTACTS where MPHONEPREFIX = '573'
>
> Will there be extra overhead using UNION?
>
> Thanks,
> - Jason 
Technical Details
Message-ID: <472f4c08@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <472bd113$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,2a474cfcc7aa1454
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "asf" <asdf>
Newsgroups: borland.public.interbase.sql
References: <472bd113$1@newsgroups.borland.com>
Subject: Re: Speed Difference
Date: Mon, 5 Nov 2007 09:04:01 -0800
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.3959
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 66.102.131.254
Message-ID: <472f4c08@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1194281992 66.102.131.254 (5 Nov 2007 08:59:52 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail