Re: why excute query through JDBC much slow than query analyzer?
From: Carb Simien [MSFT] (CarbinoS_at_online.microsoft.com)
Date: 11/22/04
- Next message: Carb Simien [MSFT]: "RE: "The operation was cancelled at the user's request" error during mass insertions"
- Previous message: Joe Weinstein: "Re: Kinda urgent Connection error messages"
- In reply to: Andrew: "Re: why excute query through JDBC much slow than query analyzer?"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Nov 2004 18:30:19 GMT
--------------------
| Thread-Topic: why excute query through JDBC much slow than query analyzer?
| thread-index: AcTQZPB2r5/CZ3pBT2+Q8N5HdzagcQ==
| X-WBNR-Posting-Host: 203.116.61.131
| From: =?Utf-8?B?QW5kcmV3?= <Andrew@discussions.microsoft.com>
| References: <C14CE83B-A2A2-4DEB-9E03-00F9893458C8@microsoft.com>
<eYCEgTnxEHA.3908@TK2MSFTNGP12.phx.gbl>
<#kauUJpzEHA.260@TK2MSFTNGP11.phx.gbl>
| Subject: Re: why excute query through JDBC much slow than query analyzer?
| Date: Sun, 21 Nov 2004 23:29:02 -0800
| Lines: 47
| Message-ID: <33D4A0B8-AB36-47D1-BEDC-6B3E97FD673C@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.sqlserver.jdbcdriver
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
| Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.jdbcdriver:6498
| X-Tomcat-NG: microsoft.public.sqlserver.jdbcdriver
|
| Thanks for all of your answers, Yes,
"SendStringParametersAsUnicode=false"
| can help me to solve the problem. But I am still curious:
|
| 1. How does this key-value-pair help? Does it force my jdbc query to make
| use of index, or it simly speed up unicode data transmitting?
|
| 2. Is it MS SQL server specific? I could not find any info about this in
| JDBC spec.
|
| Regards
| Wang
|
| "Frank Brouwer" wrote:
|
| > If you use that be aware of the fact that language specific characters
(like
| > the Euro sign) are not stored in the database because they are unicode.
| > Either do not use language specific characters or use nvarchar for your
| > strings (ntext).
| >
| > Regards,
| >
| > Frank.
| >
| >
| > "Pete Loveall" <psl@ametx.com.NO_SPAM> wrote in message
| > news:eYCEgTnxEHA.3908@TK2MSFTNGP12.phx.gbl...
| > > Set SendStringParametersAsUnicode=false This defaults to true which
| > causes
| > > searches to be done as N'text on non-unicode keys. This can cause
massive
| > > slow downs in execution.
| > >
| > > Pete Loveall
| > > AME Corp.
| > >
| > > "Andrew" <Andrew@discussions.microsoft.com> wrote in message
| > > news:C14CE83B-A2A2-4DEB-9E03-00F9893458C8@microsoft.com...
| > > >
| > > > I run a query through JDBC driver, it takes me about 60 seconds.
But I
| > > > simpy
| > > > cut/paste the query to the query analyzer (on the same machine), I
got
| > > > less
| > > > than 1 second. Why got so big difference?
| > >
| > >
| >
| >
| >
|
The SendStringParametersAsUnicode is a connection string attribute that is
implemented in the Microsoft JDBC driver. By default, all string
parameters are sent as Unicode (SendStringParametersAsUnicode=true).
If you capture the Execution Plan in a SQL Profiler trace while executing
your code, you will see the datatype nvarchar(4000) being used for your
string parameters. If your database table doesn't use Unicode data types,
then a conversion is necessary from nvarchar to varchar. This can result
in suboptimal performance.
If you set SendStringParametersAsUnicode=false in your code, the same query
will use varchar(8000) in the execution plan. Since no extra conversions
are required, this typically results in a faster execution.
Carb Simien, MCSE MCDBA MCAD
Microsoft Developer Support - Web Data
Please reply only to the newsgroups.
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
- Next message: Carb Simien [MSFT]: "RE: "The operation was cancelled at the user's request" error during mass insertions"
- Previous message: Joe Weinstein: "Re: Kinda urgent Connection error messages"
- In reply to: Andrew: "Re: why excute query through JDBC much slow than query analyzer?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|