go backarticles

Articles of SQLschool.gr Team

Why you must choose correctly the size of each field in a table

Antonios Chatzipavlis

Κάθε φορά κατά την διάρκεια ενός μαθήματος ή μιας παρουσίασης που κάνω με θέμα το σχεδιασμό μιας database και των tables αυτής όταν επίμονα τονίζω ότι πρέπει να επιλέγουμε με πραγματικά κριτήρια το μέγεθος κάθε field που θα βάλουμε στο table και όχι με την λογική βάλε κάτι μεγάλο γιατί δεν ξέρεις τι θα γίνει στο μέλλον, με κοιτάνε αρκετοί περίεργα.

Με κοιτάνε περίεργα γιατί απλά βλέπουν μόνο το field αλλά δεν βλέπουν το scaling της database.

Για να το πως λοιπόν όσο απλούστερα γίνεται.

Έστω ότι σε ένα πεδίο βάζω 1 byte λιγότερο γιατί πραγματικά είδα ότι δεν μου χρειάζεται τότε σε ένα πίνακα με 1.000.000 εγγραφές κερδίζω 1 ΜΒ τόσο σε χώρο στο δίσκο όσο και στην μνήμη της buffer cache.

Με την ίδια λογική δείτε το παρακάτω πίνακα και αποφασίστε μόνοι σας για το αν πρέπει να δαπανήσετε μυαλό και χρόνο σε κάτι τέτοιο.

Bytes Saved per Row Number of Rows in Table MB saved in Table/Database
1 1.000.000 1
1 10.000.000 10
1 100.000.000 95
1 1.000.000.000 954
8 1.000.000 8
8 10.000.000 76
8 100.000.000 763
8 1.000.000.000 7.629
16 1.000.000 15
16 10.000.000 153
16 100.000.000 1.526
16 1.000.000.000 15.259
32 1.000.000 31
32 10.000.000 305
32 100.000.000 3.052
32 1.000.000.000 30.518
64 1.000.000 61
64 10.000.000 610
64 100.000.000 6.104
64 1.000.000.000 61.035


//antonch


Antonios Chatzipavlis

Antonios Chatzipavlis

Antonios is a Data Solutions Consultant and Trainer. He has been working in IT since 1988. In his career, he has worked as senior developer, IT Manager, Solutions Architect and IT Consultant. Since 1995 he has been devoted on new technologies and software development tools, mainly by Microsoft, either by training company staff and colleagues or assisting them in design, development and implementation as a consultant or chief developer. He has focused in Databases and Data Science since 1995. He specialized in Microsoft SQL Server since version 6.0 in areas like SQL Server Internals, Database Design and Development, Business Intelligence and in 2010 he has started working with Azure Data Platform, NoSQL databases, Big Data Technologies and Machine Learning. He is an active member of many IT communities in Greece, answering colleagues' questions and writing articles in his web site. He is the owner of SQLschool.gr which is a community portal with a lot of information about Microsoft SQL Server. He has been a Microsoft Certified Trainer (MCT) since 2000. Microsoft honored him as MVP on Data Platform due to his activities in SQL Server since 2010. He holds a large number of Microsoft Certifications and Microsoft SQL Server Certifications since version 6.5.


Relative Articles

Leave your comment

COMMENT

FULL NAME

EMAIL ADDRESS

We use Gravatar

WEB SITE



captcha


 

Newsletter

If you want to receive updates from us subscribe below with your email.
Follow us in
PASS chapter logo

The Official PASS Local Group for Greece

About us Contact us Terms of Use Privacy Sing in Register
sql school greece logo
© 2010-2020 All rights reserved

This site uses cookies for operational and analytics purposes only. By continuing to browse this site, you agree to their use.