Page 1 of 1

sql parameters performance

Posted: Mon 19 Mar 2007 21:37
by Hengyi
I wrote a Insert statement that uses parameters. There seems to be 3 ways to specify the parameters:

Method 1:
INSERT INTO table (a, b) VALUES (?, ?), (?, ?)

Method 2:
INSERT INTO table (a, b) VALUES (:p1, :p2), (:p3, :p4)

Method 3:
INSERT INTO table (a, b) VALUES (@p1, @p2), (@p3, @p4)

Which is the right (or recommended) way to do it? Also if the sql command has hundreds of parameters, I noticed that (1) is the fastest while (3) is the slowest. Why is that?

Thanks,
Hengyi

Posted: Tue 20 Mar 2007 07:15
by Alexey
There is no difference in performance, actually. You can use the way which suits your needs the best.

Posted: Tue 20 Mar 2007 17:47
by Hengyi
However, I did a test using a big Insert statement with 6000 parameters (The table has 26 columns and 230 rows are inserted in one statement). The performance diffs a lot.

Method 1: 30 ms
Method 2: 600 ms
Method 3: 1200 ms

Thanks,
Hengyi

Posted: Wed 21 Mar 2007 10:12
by Alexey
We will check this carefully.
Please send me your test project including the definition of your own database objects and data dump.
Use e-mail address provided in the Readme file.
Do not use third party components.

Posted: Wed 21 Mar 2007 18:49
by Hengyi
I've sent you the test program. Thanks.

Posted: Thu 22 Mar 2007 07:28
by Alexey
Your program is being investigated.
Look forward to hearing from me again.