473,657 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use of large field definitions for small values

Hi
This is a question of "what does it cost me".

Lets say I have an integer value which would fit into a smallint field
but the field is actually defined as int or even larger as bigint.
What would that "cost" me ? How would definitions larger than I need for
the values in the field affect me ?
Its obvious that the volume of the database would grow but with the size
of resources etc that we have nowadays disc space isn't a problem like
it used to be and i/o is much faster and many people would tell me "who
cares" , or IS it a problem ?
How does it affect performance of data retrieves ? Searches ? Updates
and inserts ? How would it affect all db access if tables are pointing
at each other with foreign keys ?

Thanks !

David Greenberg

Aug 2 '07 #1
3 1489
On Aug 2, 1:46 pm, David Greenberg <davi...@iba.or g.ilwrote:
Hi
This is a question of "what does it cost me".

Lets say I have an integer value which would fit into a smallint field
but the field is actually defined as int or even larger as bigint.
What would that "cost" me ? How would definitions larger than I need for
the values in the field affect me ?
Its obvious that the volume of the database would grow but with the size
of resources etc that we have nowadays disc space isn't a problem like
it used to be and i/o is much faster and many people would tell me "who
cares" , or IS it a problem ?
How does it affect performance of data retrieves ? Searches ? Updates
and inserts ? How would it affect all db access if tables are pointing
at each other with foreign keys ?

Thanks !

David Greenberg
Less data can fit in a page....This will degrade performance.

Let say we have a single column table which is BigInt which you could
have declared as INT

over the period the data grown up to several hundered pages....say
10000 pages

If you could have used int instead of bigint it woluld have only
consumed 5000 pages for the same amount of data.
This is about storage. and caching

Now abt the CPU.
suppose you run a sum() on a coloumn of bigint it will require more
than twice the time of CPU as of Int. as CPU has to manupulate 8 bytes
instead of 4 bytes.
So your select will be slow,update/insert will be slow (more chances
of page split). Delete will be slow.
cache hits will be low (as low page fit on Memory).
CPU consumption will be high.
Backup/Restore would have been faster with the less pages.
That all I can think of now there may be more downsides

Hope it helps
Thanks
Shiju Samuel
Aug 2 '07 #2
>This is a question of "what does it cost me". <<

Data integrity. If you allow a NVARCHAR(50) for a ZIP code, like a
lot of newbies do, you will get a 50 character ZIP code in Chinese one
day. The cost in storage and access time is minimal compared to
getting the wrong answers.

Aug 3 '07 #3
Hi David,

A lot of people who dev think single user when they are writing queries; say
a query costs 10,000 logical reads thats around 78MBytes of data SQL Server
needs to process (through memory and CPU); that is fine for a single
concurrent user but what happens when 100 people run it and now the box has
to process 78MBytes x 100 = 7,800MBytes? Memory speed becomes a limiting
factor, memory is only good for a few GBytes per second of data transfer.

So, to answer your question, if your data volumes are such and you just
bloat column sizes out then you will reduce your scalability threshold, you
will also increase the size of backups, the size of data transmitted between
server and clients (again, cost that out for the number of users you have
concurrently).

Anyway, this is academic because you should size columns acording to the
data that will fit in there; for instance if you had a column that held the
number of minutes in a day then we know that is finite and is between 0 and
1,440 so that will fit in smallint so that's all you need; no point in
making it int or especially not bigint.

Hope that helps David.

Tony

--
Tony Rogerson, SQL Server MVP
http://sqlblogcasts.com/blogs/tonyrogerson
[Ramblings from the field from a SQL consultant]
http://sqlserverfaq.com
[UK SQL User Community]
"David Greenberg" <da*****@iba.or g.ilwrote in message
news:46******** ******@iba.org. il...
Hi
This is a question of "what does it cost me".

Lets say I have an integer value which would fit into a smallint field but
the field is actually defined as int or even larger as bigint.
What would that "cost" me ? How would definitions larger than I need for
the values in the field affect me ?
Its obvious that the volume of the database would grow but with the size
of resources etc that we have nowadays disc space isn't a problem like it
used to be and i/o is much faster and many people would tell me "who
cares" , or IS it a problem ?
How does it affect performance of data retrieves ? Searches ? Updates and
inserts ? How would it affect all db access if tables are pointing at each
other with foreign keys ?

Thanks !

David Greenberg
Aug 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
6367
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but something I'll need in this case is some experience-based set of rules about how to use python in this context. For example... is defining readonly attributes in classes worth the hassle ? Does duck-typing scale well in complex
4
4141
by: jeff brubaker | last post by:
Hello, Currently we have a database, and it is our desire for it to be able to store millions of records. The data in the table can be divided up by client, and it stores nothing but about 7 integers. | table | | id | clientId | int1 | int2 | int 3 | ... | Right now, our benchmarks indicate a drastic increase in performance if we divide the data into different tables. For example,...
4
5401
by: Mal | last post by:
I have an ACC 2000 database that has a strange behaviour I have a small table, with just a few fields... My report has very simple grouping and sorting, no code bar a NODATA event. I have a memo field When CAN GROW is set to NO everything works just fine. When CAN GROW is set to YES - watch out.... One record causes BIG
24
4030
by: Salad | last post by:
Every now and then I see ads that state something like "Experience with Large Databases ...multi-gig...blah-de-blah" And I have to laugh. What's the difference between a large or small database? A table is a table, a record is a record, a field is a field. All you are doing is manipulating data in tables. I wouldn't think it'd make much difference in working with a table with 10 records or a billion records...they're nothing more than...
2
8422
by: David Garamond | last post by:
I was thinking on how one would design an optimal (performance-wise) database of large number of schedules with crontab-like semantic. There will potentially be hundreds of thousands or even millions of "crontab" entries, and there will be a query run once every minute to determine which entries are to be run for that minute. The primary goal is, of course, for the query to run as fast as possible. My first stab is, straightforward...
2
1866
by: mvl_groups_user | last post by:
I am trying to look up data on about 1000 records from a 6 million record view on a DB2 database using msaccess. The 6 million record DB2 view is connected through a linked ODBC table (table A), and the 1000 primary key numbers I want are in a local msaccess table (table B). The most obvious solution is to join table A and B, but this is excruciatingly slow performance-wise.
6
1965
by: MLH | last post by:
I have a query (SQL below) that operates on values entered by users into an unbound form to append a record to tblAdmin. I do not under- stand the basis for the error. There are some 17 or so data entry fields on the form housing perhaps 600-700 characters between the lot of them. Why might Access 97 need to err on such a simple operation? SQL: INSERT INTO tblAdmin (TowCompany, TowCoAddr, TowCoCity, TowCoState, TowCoZip, TowCoCounty,...
0
2697
by: NM | last post by:
Hello, I've got a problem inserting binary objects into the postgres database. I have binary objects (e.g. images or smth else) of any size which I want to insert into the database. Funny is it works for files larger than 8000 Bytes. If a file is less than 1000 Bytes I get the following message: Error message: --invalid input syntax for type oid: "\074\077......";
7
6713
geolemon
by: geolemon | last post by:
I'm getting an error, I'm not seeing the cause: Debug highlights this segment of code (I just snipped a portion here): strProc = "Insert into Parts (MfgPN, Manufacturer, Description)" & _ "select distinct PurchasedPN, Manufacturer, Description " & _ "from DBimport where PurchasedPN is not null " & _ "and PurchasedPN not in (select MfgPN from Parts) " & _ "group by...
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.