🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Speed Difference

#693
From: Jason Summers
Date: Sat, 03 Nov 2007 01:38
22 lines
1690 bytes
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: <472bd113$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,2a474cfcc7aa1454,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: Speed Difference
Date: Fri, 2 Nov 2007 20:38:04 -0500
Lines: 23
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: <472bd113$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1194053907 64.251.145.50 (2 Nov 2007 18:38:27 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
X-Original-Bytes: 1522