Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / October 2005

Tip: Looking for answers? Try searching our database.

No Queries Just SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DS - 12 Oct 2005 19:45 GMT
If I got rid of all my saved Queries and just used SQL would there be
any benifit to to this?
Thanks
DS
Brendan Reynolds - 12 Oct 2005 19:59 GMT
There are pros and cons either way. In my opinion, the pros and cons pretty
much balance each other out, to the extent that neither approach has a
conclusive advantage over the other, and it comes down to personal
preference.

Signature

Brendan Reynolds

> If I got rid of all my saved Queries and just used SQL would there be any
> benifit to to this?
> Thanks
> DS
mscertified - 12 Oct 2005 21:39 GMT
Saved queries run faster than SQL in code because they are partially compiled
upon saving. You also know the SQL is correct since Access syntax checks it.
That said you can build SQL dynamically in code which is very powerful.
Personally, I use a mix of both.

Dorian.

> If I got rid of all my saved Queries and just used SQL would there be
> any benifit to to this?
> Thanks
> DS
Albert D.Kallal - 12 Oct 2005 22:12 GMT
> Saved queries run faster than SQL in code because they are partially
> compiled
> upon saving. You also know the SQL is correct since Access syntax checks
> it.
> That said you can build SQL dynamically in code which is very powerful.
> Personally, I use a mix of both.

Believe it not, pre-compiled queries are not always faster in terms of
performance.
If that query has got any parameters, then building the sql string is
actually faster.

The problem is that query compile time is very small.

When you use in-line sql, you FORCE the query optimizer to re-compile. This
actually means that the JET engine often does a BETTER job when you force a
re-compile each time.

I have experienced this in-line speed advantage over querydefs with
parameters, and to quote from the JET white paper page 18, we get:

<quote>

Check Parameterized Queries for Optimal Performance

Parameterized queries can only be implemented by using a stored query. Since
stored queries have a precompiled query plan, parameterized queries that
contain parameters on indexed columns may not execute efficiently. Since the
query engine does not know the values to be passed in a parameter in
advance, it can only guess as to the most efficient query plan.  Based on
customer performance scenarios that we have examined, we have discovered
that in some instances substantial performance gains can be achieved by
replacing a stored parameterized query with a temporary query. This means
creating the SQL string in code and passing it to the DAO OpenRecordset or
Execute methods of the Database object.

</quote>

Note the word "substantial performance gains", and I seen the above many
times...

It is important to point out that use of quires is generally preferred since
to go on a wild goose hunt everytime to change some sql in code is rather a
maintains nightmare. If  you can put the sql in saved quires, then you
should.

Of course, I like as you mentioned, you use a mix of both, and that is
really the answer.

Signature

Albert D. Kallal   (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal

George Nicholson - 12 Oct 2005 23:25 GMT
In addition, (but this goes back to Access 97 and may no longer be as much
of an issue), as a general rule, saved & compiled queries don't contribute
to database bloat as much as having SQL strings as Recordsources,
Rowsources, etc. can.

HTH,
Signature

George Nicholson

Remove 'Junk' from return address.

>> Saved queries run faster than SQL in code because they are partially
>> compiled
[quoted text clipped - 46 lines]
> Of course, I like as you mentioned, you use a mix of both, and that is
> really the answer.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.