Article View: borland.public.interbase.sql
Article #267Re: Speed with Procedure
From: Thomas Steinmaurer
Date: Thu, 07 Feb 2008 14:42
Date: Thu, 07 Feb 2008 14:42
45 lines
2037 bytes
2037 bytes
> Only to understand query speed with Procedure, If I > > CREATE PROCEDURE Proc_1 > returns ( cod1 varchar(10), cod2 smallint, cod3 smallint) > as > begin > for > Select cod1, cod2, cod3 from Tab1 > where cod2>cod3 > into:cod1, :cod2, :cod3 > do suspend ; > end > > and I query it with > > Select * from Proc_1 > where cod1 = 'test1' > > a) Proc1 select only record matching the where clause of the query, or The SP won't be able to use an index on cod1 in this case. This is the main difference to a view regarding optimizing a WHERE clause. > b) Proc1 retrives before all its records and after query select those > required by its where condition ? Yep. > Following construct should be faster than previous ? Yep, it should, if there is an index on cod1. Check the execution plan of both statements and figure out if an index on cod1 will be used in both cases. ;-) -- Best Regards, Thomas Steinmaurer LogManager Series - Logging/Auditing Suites supporting InterBase, Firebird, Advantage Database, MS SQL Server and NexusDB V2 Upscene Productions http://www.upscene.com
Technical Details
Message-ID:
<47ab18dd$1@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-mailReferences:
<47ab0bac@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,ddeb009208f7937f X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 07 Feb 2008 15:42:57 +0100 From: Thomas Steinmaurer <t.steinmaurer_dontbugmewithspam@upscene.com> User-Agent: Thunderbird 1.5.0.14 (Windows/20071210) MIME-Version: 1.0 Newsgroups: borland.public.interbase.sql Subject: Re: Speed with Procedure References: <47ab0bac@newsgroups.borland.com> In-Reply-To: <47ab0bac@newsgroups.borland.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 193.186.164.88 Message-ID: <47ab18dd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1202395357 193.186.164.88 (7 Feb 2008 06:42:37 -0700) Lines: 45 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