• 18 Posts
  • 178 Comments
Joined 10 months ago
cake
Cake day: May 28th, 2024

help-circle
  • When it comes to searching the database, the index will have already been created. When you create an index, it might take a while as the database engine reads all the data and creates a structure to shadow it. Each engine is probably different and I don’t know if any work exactly like that, but it’s an intuitive way to understand the basics of how B-trees work. You don’t really need to think much about how it works, just that if you want to use a column as a filter, you want to index it.

    However, when you’re thinking about the structure of a database it’s a good idea to think what you’ll want to do with it before hand and how you’ll structure queries. Sometimes searching columns without an index is unavoidable and then you’ve got to come up with other tricks to speed up your search. Like your doctor might find you (i’m presuming gaz is sort for gary and/or gareth here) with a query like SELECT * FROM patients WHERE birthdate = "01-01-1980" AND firstname LIKE "gar%" The db engine will first filter by birthdate which will massively reduce the amount of times it has to do the more intensive LIKE operation.



  • If there’s something you want to search by in a database, you should index it.

    Indexing will create an ordered data structure that will allow much faster queries. If you were looking for the username gazter in an unindexed column, it would have to check literally every username entry. In a table of 1000000 entries it would check 1000000 times.

    In an indexed column it might do something like ask to be pointed to every name beginning with “g”, then of those ask to be pointed to every name with the second letter “a” and so on. It would find out where in the database gazter is by checking only six times.

    Substring matching is much more computationally difficult as it has to pull out each potentially matching value and run it through a function that checks if gazter exists somewhere in that value. Basically if you find yourself doing it you need to come up with a better plan.

    Cartesian explosion would be when your query ends up doing a shit load of redundant work. Like if the query to load this thread were to look up all the posters here, get all their posts, get the threads from those posts and filter on the thread id.





  • Tempered glass, the type which is used for stuff like shower screens or car windows is under constant tension against itself. The inside of the glass wants to be bigger than the outside. Normally this makes it harder to break as the bonds on the outside are so strong and uniform they prevent it from bending or shearing as easily as normal glass.

    The problem is that if you manage to break those bonds, the outside can very rapidly tear itself apart as it finds a way to relieve that tension. It basically pops like a balloon. The reason it breaks into small pieces is because anything bigger is still under tension and once the surface is damaged the crack will spread to ease it.

    So your glass could have had a defect or damage which broke a few of those bonds, and heat cycles eventually pushed it to break the next bond along and start a chain reaction which destroyed the whole thing.

    Edit: it could even be that some grit fell in the housing or something. The reason spark plugs break car windows is because the edges are sharp enough to cut the glass with very little force.
















  • On the hottest day of the year a few years ago, the Mormons were out door knocking in their little suits. They were clearly not having a good time so we invited them in for a cold drink just to offer them some respite from the afternoon sun.

    They got me to read a passage about Joseph Smith going into a cave and feeling euphoric and were like “well how do does that make you feel” and I’m like “what? I know people who’ve had more convincing experiences than that who still aren’t religious because they knew they were on drugs”

    They came back again a few times until it was clear we’re absolutely not becoming Mormons.

    I sometimes wonder if it occurs to them that we were probably better christians than most actual Christians they’ve met, even without the blackmail.