• 1 Post
  • 28 Comments
Joined 1 year 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.









  • I’m not an econ major but I’m going to give you my theory anyway.

    We’ve been circling the drain on a major global recession for two years. We’ve been avoiding it through sheer denial.

    Nobody ever mentions it, but tech stocks were the first to take a beating in 2008. The reason is that they’re actually kinda worthless and just a place where billionaires gamble the way trust fund kids do with cryptocurrency. There’s just not really that much collateral in digital property. Unlike land, it’s value can just disappear overnight if people decide it’s uncool.

    When asset managers are about to be called on their bets and have to find money somewhere, the first thing they’ll do is sell tech shares to bail out other investments. Houses will always have some value even if you end up having to manage it yourself, whereas any social network risks going the way of MySpace.

    Twitter being in trouble isn’t just a sign that twitter is in trouble, but that investors need that money for something safer, and if they’re looking for something safer that may mean sheer denial isn’t working anymore.