Page 1 of 1

Duplicated SQL instructions getting to the server! (3.10.8.0)

Posted: Mon 25 Jun 2007 20:42
by DaviWall
Hey All,

Anyone got this problem? It's happening like this, I execute one query and the executed instruction is running two times on the server. When I use TSQLMonitor, the generated file shows 2 times the same instruction.
When I debug my application, I'm sure the instruction is executed only one time.

On the server I can keep track my Sql Instructions using the Profiler (comes with SQLSERVER). It also shows that 2 exact SQL instructions are consuming time.

Is it a known problem in the driver, or maybe its just an configuration issue?

regards,

Please I really need help on this...

Posted: Tue 26 Jun 2007 13:37
by DaviWall
Hey again, I guess nobody had this problem huh? Oh Well! At least someone could give me any idea how to find what's causing this problem?

If I change the driver to Dephi standard DBExpress library everything works correcly. But Delphi standard DBExpress library has some bugs and I can't use it. CRLab drivers work fine, but I'm having this problem that duplicates de SQL sent to the server. I found this problem only using DBExpress for SQLSERVER.

I'm using TSqlMonitor to monitor all statements sent to the server. Everytime I run a Query, SqlMonitor shows that two "select's" are sent to the server as well as SQLProfiler.

Posted: Tue 26 Jun 2007 15:48
by Antaeus
SQL Server Profiler displays each query twice. One time when the batch is started, one time when it is completed.
If this is not the matter, please check wether the problem is reproduced with one of DbxSda demo projects.

Posted: Tue 26 Jun 2007 16:35
by DaviWall
Antaeus

I guess you didn't read the entire sentence. Your support wasnt helpfull.
I know that SQLProfiler shows one time when batch is started, one time when it is completed.(when I meant it was being executed twice, it means it was showing 4 times in the profiler)
I also know that this is just an option and you can turn it off. I also know how to use TSQLMonitor and I also know that TSQLMONITOR IS SHOWING THE SQL INSTRUCTION BEING EXECUTED 2 TIMES.

When I use DBExpress standard this problem doesnt happen.
When I use CRLAB Library for FireBird or Oracle this problem doesnt happen.
When I track the event OnTrace (TSQLMonitor), there is a variable that tells me the operation of the sql instruction. All operations returned are ERROR's. Funny that there is no error in the instruction and the rows are returned without problems.

The only thing I don't know is how to reproduce this problem outside the application.
I thought somebody from here could give me some helpfull idea, or at least try to. Not give me this non-critical-sense answer.

Posted: Tue 26 Jun 2007 16:52
by Antaeus
I removed the new thread, you have created, because it is related to the problem that is under discussion here. Please do not duplicate threads in the future.

Posted: Tue 26 Jun 2007 16:58
by Antaeus
The information you have provided is not enough to find out the reason of the problem. We are unable to find a solution to this problem if we do not have enough information.

Did you try to execute your query with a DbxSda demo (e.g. the Query demo)? What is the result?

Posted: Tue 26 Jun 2007 17:35
by DaviWall
Antaeus,

I tried to reproduce the problem with a small application and I can't. The application I work on is an ERP tecnology system, it's not a small project.
I'm basically using the same structure to try to reproduce the problem and is just not happening.

I wonder if this is some kind of Connection or Query configuration that may be causing the problem. Like Prepare property?

We bought CRLAB drivers so I have the source code. Maybe you could give me directions on how to track this problem debugging the source code.
We are having performance issues and this is one of the key problems.

Thank you.

I REPRODUCED THE PROBLEM!!!

Posted: Tue 26 Jun 2007 19:00
by DaviWall
Ok Antaeus,

I got it, I reproduced the problem. Its kinda simple.

Build a new application having this structure..

SQLCONNECTION <- SQLQUERY <- DataSetProvider <- Clientdataset

Now.. in the event BeforeOpen of the ClientDataSet add this line..

ClientDataSet.FieldDefs.Update;

This command will run the query right before it actually opens.
It only happens in SQL SERVER DRIVER.

If you still cannot reproduce it, I will be glad to send it to you the application, just let me know how you want it to be sent.

Than you.

feedback

Posted: Wed 27 Jun 2007 12:24
by DaviWall
Is anybody checking this issue? Can I have a feedback on this?

I know you guys must be busy, but I really needed a feedback on this because this is causing many performance problems with our customers.

Thank you

Posted: Wed 27 Jun 2007 13:09
by Antaeus
In order to get fields descriptions on updating FieldDefs, DbxSda and the standard driver use different approaches. The standard driver prepares the query. DbxSda sends the query to the server, but records are not actually fetched. In any case driver should perform a roundtrip to the server in order to get fields description. Preparation is not an optimal approach beacause of some restrictions. For example, not all queries can be prepared, in certain cases results of prepared and not prepared queries are different. We will try to optimize behaviour of DbxSda on updating FieldDefs.

Try to give up using FieldDefsUpdate where it is possible.

Posted: Wed 27 Jun 2007 19:20
by DaviWall
I understand your explanation. But see even thought records are not being fetched, this instructions are consuming time on the server.

We have only one case where we need to use FieldDefsUpdate and it's not because we wanna use it, it's because there is a pontencial bug in the DBClient where it is not updating the fielddefs where it should.

Anyway, I hope you can find a way to workaround this problem.

Posted: Tue 24 Jul 2007 08:31
by Jackson
Preparing the query also takes some time on the server if you use the standard driver.
There is no way to get the fields description without executing or preparing the query.
We sure that executing the query without fetching the data to get its fields description is much better way rather than preparing it.
We will try to make some performance optimization but it can't be significant.