i have the foll id's (sample 2005053110073148) generated by a function. I
need to store the data in a table. What is
the best datatype should i give to the column to enhance performance and
storage.
ThanksIt looks like the return data is of a "datetime" datatype. (Close but not
exact.)
If you can use the "datetime" datatype, use it. if not, use Char(16). This
assumes the result is always 16 bytes. Stay away from "varchar" here if the
results are always a fixed length.
"Chris" wrote:
> i have the foll id's (sample 2005053110073148) generated by a function. I
> need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance and
> storage.
> Thanks|||Chris wrote:
> i have the foll id's (sample 2005053110073148) generated by a
> function. I need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance
> and storage.
> Thanks
CHAR or DECIMAL. A CHAR would require 16 bytes of storage. A DECIMAL
would require 9 bytes of storage. Can you provide more detail about what
this number is.
-
David Gugick
Quest Software
www.imceda.com
www.quest.com|||It depends on whether this id has any meaning, what
the possible values of this id are, and how it will be
used in the bigger picture. Few if any questions
about database design that can be answered without any
context, and this is not one of them.
If you need to interpret all or part of it as a date/time, store that
part as a datetime (or smalldatetime if one-minute precision
is enough). If this is "just an identifier" and you will never
need to interpret anything except perhaps the ordering,
decimal(16,0) may be a good choice (or decimal(bigger#,0),
if these can be longer). If some of the positions can contain
characters other thhan 0-9, you'll need a character type.
Steve Kass
Drew University
Chris wrote:
>i have the foll id's (sample 2005053110073148) generated by a function. I
>need to store the data in a table. What is
>the best datatype should i give to the column to enhance performance and
>storage.
>Thanks
>|||Hi,
Sorry about the details. The (2005053110073148) is just an identifier. I
won't need to interpret anything. It's just there to identify a group of
record. I have a function that takes the datetime and then concatenate a
randum number at the end. It's being returned from the function as a string
so the parameter in my sp is accepting it in a output variable as
declare @.id nchar(17)
Thanks
"Chris" wrote:
> i have the foll id's (sample 2005053110073148) generated by a function. I
> need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance and
> storage.
> Thanks|||I used nchar(17) because I see in BOL nchar is 4000. Is that a good choice?
"Chris" wrote:
> i have the foll id's (sample 2005053110073148) generated by a function. I
> need to store the data in a table. What is
> the best datatype should i give to the column to enhance performance and
> storage.
> Thanks|||If it's all digits, and there are never any leading zeros,
nchar(17) is a bad choice. It takes 34 bytes per value,
which is about 4 times as much storage as you probably
need. If 17 digits is the maximum possible length (this one
is 16 digits) and it will always be a string of digits with no
leading zero, decimal(17,0) is a better choice. Or you could
use bigint, which would save one more byte per value.
SK
Chris wrote:
>I used nchar(17) because I see in BOL nchar is 4000. Is that a good choice?
>"Chris" wrote:
>
>
Showing posts with label datatype. Show all posts
Showing posts with label datatype. Show all posts
Wednesday, March 28, 2012
Tuesday, March 20, 2012
Performance and tuning in SQL Server 2000
I have 2 table around 60 million records and grow substantially. The table i
s
created with non-clustered index (int datatype). Jobs are scheduled and
running in the background. Is there any way to see in the profiler what
queries are being run. I could not see the queries as the jobs are running.
How do i need to optimize the query in case i get the query.If you are using SQL Server 2005, you can save a .trc file (started before
the job rns and ending afterward) and give it to the database engine tuning
advisor.
In SQL Server 2000, you can do something similar with the index tuning
wizard.
A
"Sathya" <Sathya@.discussions.microsoft.com> wrote in message
news:558C10E8-7555-475C-852D-BF71685618F4@.microsoft.com...
>I have 2 table around 60 million records and grow substantially. The table
>is
> created with non-clustered index (int datatype). Jobs are scheduled and
> running in the background. Is there any way to see in the profiler what
> queries are being run. I could not see the queries as the jobs are
> running.
> How do i need to optimize the query in case i get the query.
s
created with non-clustered index (int datatype). Jobs are scheduled and
running in the background. Is there any way to see in the profiler what
queries are being run. I could not see the queries as the jobs are running.
How do i need to optimize the query in case i get the query.If you are using SQL Server 2005, you can save a .trc file (started before
the job rns and ending afterward) and give it to the database engine tuning
advisor.
In SQL Server 2000, you can do something similar with the index tuning
wizard.
A
"Sathya" <Sathya@.discussions.microsoft.com> wrote in message
news:558C10E8-7555-475C-852D-BF71685618F4@.microsoft.com...
>I have 2 table around 60 million records and grow substantially. The table
>is
> created with non-clustered index (int datatype). Jobs are scheduled and
> running in the background. Is there any way to see in the profiler what
> queries are being run. I could not see the queries as the jobs are
> running.
> How do i need to optimize the query in case i get the query.
Subscribe to:
Posts (Atom)