Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Char and varchar - performance problem
Message
De
20/07/2009 20:31:21
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
20/07/2009 13:41:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01413408
Message ID:
01413484
Vues:
160
>Hello
>
>I submit a query via SQLexec. The query looks basically like this (it is actually much more complex)
>
>SELECT * FROM TABLEX WHERE FIELD1 = ?AMES
>
>Where AMES = "200905" (VFP variable)
>
>It takes very long to complete (say 20 minutes). Using SQL profiler, I detect that SQL server does this:
>
>
>exec sp_executesql N'SELECT * FROM TABLEX WHERE FIELD1 = @P1',N'@P1 varchar(6)','200905'
>
>Running this from Query Analyzer runs slowly too.
>
>However, FIELD1 is actually char(6) not varchar(6). There is an index on FIELD1.
>
>From query analyzer, changing just varchar(6) to char(6), slashes execution time down from 20 minutes to 6 seconds.!
>
>How can I force VFP (or the ODBC driver) to correctly use char instead of varchar?
>
>Using SQL 2005 with SQL Client.

Beat the enemy with their own weapon:
sqlexec(h, [exec sp_executesql N'SELECT * FROM TABLEX WHERE FIELD1 = @P1',N'@P1 char(6)',']+AMES+['], [somealias])

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform