Slow OleDbParameter

  • Thread starter Thread starter Tomislav Stilinoviæ
  • Start date Start date
T

Tomislav Stilinoviæ

Hi all,
I have a question about performance of OleDbCommand with command
parameters. I try to get records from table with 1500000 records in two
ways,
with command parameters (a) and without them (b). Field type is char and it
also has index. Option (a) gives me result in 30 seconds and option
(b) in 0.15 seconds. With SqlCommand results are the equal.

Any ideas?

Dim t As New DataTable
Dim cmd As New OleDbCommand
Dim cnn As new OleDbConnection(".....")
Dim rdr As oledbDataReader


(a)
cnn.open()
cmd.connection=cnn
cmd.CommandText = "SELECT * FROM Table WHERE Field >= ? AND Field <= ?"
cmd.Parameters.Add("P1", "Value1")
cms.Parameters.Add("P2", "Value2")
rdr=cmd.ExecuteReader
(b)
cnn.open()
cmd.connection=cnn
cmd.CommandText = "SELECT * FROM Table WHERE Field >= 'Value1' AND Field <=
'Value2'"
rdr=cmd.ExecuteReader


Thanx in advance.
Tomislav
 
Hi Tomislav,

Seems to me like some sort of sql command caching issue.
What happens if you restart Sql server and do (b) again?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top