Web search 30M rows sub-second, cheaply
quantblog.wordpress.com
quantblog.wordpress.com
Of course, performance won't be stellar if it has to go to disk to find every result, but even with that you should be able to get sub-second results with some tweaking.
I guess I assumed the entry-point is a 2 to 4 node cluster ? But this may be my own wrong assumptions.. they may be really ram efficient.
I confess I have a somewhat irrational dislike of what I call big-java .. I really wanted to like Cassandra+Spark for instance, but the install is just such a heavy download of code, I just feel an aversion to installing that.
I have worked with Java, but not recently.. there may be incredibly efficient and small codebases that belie the big-java stereotype.
Iv'e been enjoying the node.js / npm ecosystem myself - but I know smart people who love java-land. We can tolerate each others rants and still share a beer :]
The Lucene-based search engines are also very well optimized. I'd tend to think of a 30M row dataset as a single machine size unless you need failover or the records are quite large.
Wow, that is definitely the opposite of true.
The main takeaway is really how fast SSDs are and how much bang for your buck you can get on a single commodity host instance [ thru some creative wrangling of data structures ]
I will endeavor to followup with a fair comparison using postgres...
Can you suggest the best approach / config to keep the top-index working set in ram ?
I do share your conclusion that SSDs are very good value for workloads that need to do a lot of random I/O.
Regarding the best config for PostgreSQL, it really depends on the hardware. If you really want to use boxes with just 2GB of RAM, use smaller shared buffers and let the page cache do the rest.
If you need more help with tuning PostgreSQL for the benchmark later, either ping me at tomas(at)pgaddict.com or join pgsql-performance@postgresql.org (I do occasionally lurk there, but others will surely help too).
awesome, thanks Thomas - Ill check out your blog too.
Learn your data structures. Learn what the storage engines use. Use the right structure for the right problem.
The spirit of my hack was really just that - to apply the well known data structures and algos to solve a problem.
Its unusual to want fast, large and cheap all together - if you really want to squeeze things you might look at how modern SSD performance can be exploited - my hack is just one instance of that.
I needed something similar when I was building https://acoustid.org/ and for the first iteration I used PostgreSQL's GIN indexes, which are nice and easy to work with, but once the index grew beyond some point, it was getting very slow. I spent some time designing a minimalistic inverted index that does just what I need, nothing else, while compacting the data as much as possible, to keep it in RAM, and the results were just excellent. It was super fast compared to the GIN indxes. Now I have 10x more data and it's still as fast as it was before. If you are interested, here is the code - https://bitbucket.org/acoustid/acoustid-index
[ you explain the approach much better than OP :]
http://www.postgresql.org/docs/8.3/static/textsearch-indexes...
My post should have a disclaimer - "unless you have several years using many sql and nosql datastores and some background in algorithms and data-structures - DONT DO THIS"
My reason for _not_ using postgres and its GIST style indexes and full search primitives ( which I like and use often, btw ) was that I could find no way to configure postgres to hold the full top level index in RAM. I could run thru a query over all data to load it into the working set, but ideally I would like to mark it 'preload' - do you know a way to do this ? I did consider putting the inverted index in its own postgres DB on a RAM disk, but it seemed non-recommended.
The spirit of the post was : in most cases yes you can find something good off the open source shelf.. [ particularly redis which was very close to being what I needed ] but sometimes rolling a custom data structure that fits the problem can be a surprising win.
Particularly now that SSDs give a really different performance profile to what we are used to. I think DB implementations will adapt to fit SSD characteristics better over the next couple years.. just as they have made the desktop much more snappy.
New DB engines such as rethink and aerospike are very likely tuned more towards SSDs out of the box .. I haven't spent much time with those yet.
Theres a class of problems can be solved by scaling vertically, if you approach it by creatively applying the basics of algorithms and data structures. This is why many people use redis, its a superb bag of useful data-structures you can co-opt to your needs.
Is there a reason that you're unwilling to trust Postgres's query planner/buffer cache to keep your index in RAM? Even if it didn't, the premise of the article is that SSDs are fast. You're spending an order of magnitude more time retrieving content than searching for it, so why optimize the fast part?
Also, consider that GIST or another fulltext aware index (e.g. Lucene/Sphinx/etc) should compress your index (with vints, etc) far better than your approach, and therefore both query faster and save you precious RAM.
The article itself was sparse on details, but until I learn more, this seems to me to be a classic example of optimizing before measuring.
http://dba.stackexchange.com/a/116536
But this doesn't guarantees that the data will stay in the cache because: "Prewarmed data also enjoys no special protection from cache evictions, so it is possible for other system activity may evict the newly prewarmed blocks..."
In MySQL you can create tables with the MEMORY storage engine: https://dev.mysql.com/doc/refman/5.5/en/memory-storage-engin...
A fantastic piece of software.
I'd be surprised if it's an issue these days, because:
1. It's disabled by default, and has been for a while.
2. If you do turn it on, the config options let you be more specific about where those scripts are allowed to come from.
Also 1TB of data fits easily in RAM