How do you quickly search databases that are hundreds of millions of records?
I am new here and so far I've downloaded one database of 100 million records and another database of 200 million records (the recent twitter hack). I thought that exploring these databases would be a good excuse for me to learn MySQL. So far it's been a major headache and I've spent probably at least 20 hours at it and have gotten next to nowhere. I've used ChatGPT to guide me through the process, and it has worked wonders in getting me as far as I've gotten, but I encounter error after error and have troubleshooted at least 50 different problems so far. So at the moment I'm stuck with using a large text viewer, but that will take over an hour to run a single query.
In trying to get the files to load into a MySQL table, the most common problem is with the way the databases are parsed. Whatever delimiter is used in the file always appears somewhere in the data as well. The other common problem is that these files contain weird characters that MySQL can't handle. I've even used python to try to clean the files, but that also sends me down a rabbit hole of error after error after error.
So before I put a lot more time into this, am I even headed in the right direction? I figured MySQL is a good tool to know and is meant for large databases. But is it not appropriate for databases in the hundreds of millions of records? I want to be able to search a name or e-mail and not wait more than a minute or so for the query to finish (and I know MySQL will allow me to do partitions and other time saving tricks). I don't really have an interest in using these databases in scripting. My main interest is just running simple queries on them. So are there better tools that aren't too difficult to learn or expensive to use?
9 comments
[ 4.1 ms ] story [ 31.7 ms ] threadto search for name joe as example:
> grep -r joe .
-r will do a recursive search in case you have files in folders and those folders have more folders with files
If that isn't fast enough, perhaps try feeding them into clickhouse. There is a recent talk on fosdem about how to load dumps easily into it: https://fosdem.org/2023/schedule/event/fast_data_analytical_...
MySQL by contrast is ideal for transaction processing, which is a very different problem.
I work on ClickHouse so I'm going to recommend that. It's open source and runs on everything from laptop to Kubernetes to cloud. There are multiple cloud services for ClickHouse as well, if you don't wnat to run it yourself. If you want to use ClickHouse have a look at the Altinity Quickstart for ClickHouse video on Youtube to learn how it works. [0]
[0] https://www.youtube.com/watch?v=phTu24qCIw0
I work at Altinity and did the video. There are also many other great analytic databases beside ClickHouse, including: Snowflake, BigQuery, Druid, and Redshift.
https://clickhouse.com/blog/extracting-converting-querying-l...
Had plenty of shitty query optimizations from MySQL.
But besides that, how much mb are 100million?
And what is your goal?
Look at the table names, do they tell any story?
Look at the constraints, look at the foreign keys. Do the attributes stand out in any way?
Map it out and maybe you'll find a strategy.
Then when you sit down you'll probably have a better idea what you're dealing with.
I had to migrate big databases a couple times in my career and the db expert I worked with basically didn't even think about code for a week. We were like CSI agents trying to figure out wtf is going on.
As for delimiters, escape characters, bad characters (and character sets and collation settings) and import/export techniques, these exist across databases. If the data were clean, analytics would be a quick and easy job, but it rarely is; that challenge is kind of the nature of the problem domain.