sqlschool.gr logo


Articles of SQLschool.gr Team

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

Antonios Chatzipavlis
Tuesday 25 April 2017

Κάθε φορά κατά την διάρκεια ενός μαθήματος ή μιας παρουσίασης που κάνω με θέμα το σχεδιασμό μιας 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 954
8 1.000.000 8
8 10.000.000 76
8 100.000.000 763
8 7.629
16 1.000.000 15
16 10.000.000 153
16 100.000.000 1.526
16 15.259
32 1.000.000 31
32 10.000.000 305
32 100.000.000 3.052
32 30.518
64 1.000.000 61
64 10.000.000 610
64 100.000.000 6.104
64 61.035


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.


What's New in SQL Server 2022 - Episodes

More Tips...

Become a member

If you want to receive updates from us become a member to our community.




sqlschool.gr © 2010-2024 All rights reserved

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