Can NULLs Improve your Database Queries Performance? - The Backend Engineering Show

The Backend Engineering Show with Hussein Nasser

Episode | Podcast

Date: Sun, 11 Apr 2021 19:10:34 GMT

<p>In this episode, we will discuss NULLs in database systems. I’ll go through the following:</p> <p>What is Null?</p> <p>NULLs persistence</p> <ul> <li>Whether you store a 0 or 2 billion value in the field 32bit integer field it costs 32 bit</li> <li>when you store a NULL in 32 bit integer field we save 32 bit but add overheads</li> </ul> <p>When NULLs are naughty</p> <ul> <li>Semantics and inconsistent result</li> <li>Select count(*). Includes nulls</li> <li>count(column) ignores nulls</li> <li>T is NULL returns the null rows</li> <li>T is NOT NULL returns not null rows</li> <li>T In (NULL) returns nothing</li> <li>T not in NULL returns nothing</li> <li>Some database don’t index nulls</li> </ul> <p>When NULLs are useful</p> <ul> <li>I don’t have value , I don’t wish to provide a birthday</li> <li>not applicable field for certain use cases but not others fat tables (denormlization)</li> <li>Fat tables with many columns makes your rows longer which means fewer rows fit in your page (show pic).. NULLs help here .. that are NULL, it yields shorter rows, instead of storing a default 0 value</li> </ul> <p><br /></p> <p><br /></p> <p>Support my work on PayPal</p> <p><a href="https://bit.ly/33ENps4">https://bit.ly/33ENps4</a></p> <p>Become a Member on YouTube</p> <p><a href="https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join">https://www.youtube.com/channel/UC_ML5xP23TOWKUcc-oAE_Eg/join</a></p> <p><a href="https://emojipedia.org/teacher/">🧑‍🏫</a><strong> </strong>Courses I Teach</p> <p>https://husseinnasser.com/courses</p>