Using a sql server execution plan

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Using a sql server execution plan

Post by brace » Tue 09 Mar 2010 11:41

In my application I use a very complex query. When I run that query in SQL Server management studio it takes 16 seconds to execute the first time and 2 seconds the second time. This is because the query execution plan is created.

When using it from Delphi application it is always like the first time (very slow).

Is it a way I can assign an execution plan to a query or any way I can use sdac to take advantage of this?

Or are you aware to another way to do it even if sdac doesn't support this?

Thanks.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Fri 12 Mar 2010 10:23

You can call the Prepare method of TMSQuery.

brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Post by brace » Fri 12 Mar 2010 11:57

I don't see any sugnificant difference by using Prepare.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 22 Mar 2010 09:57

Please, check that you call the Prepare method only once, and after that execute a query a few times.

brace
Posts: 227
Joined: Wed 14 Feb 2007 08:26

Post by brace » Thu 25 Mar 2010 10:47

Ok I will try.

Post Reply