Redis in my Postgres
craigkerstiens.com
craigkerstiens.com
Can I basically put up a PG instance and have that manage/proxy to all of my backend stores? It would be nice to be able to just use my one DB library to query Riak, Redis and Postgresql [my usual datastore stack]. I didn't see anything in here about doing CUD operations on the FDW stores, but the benefit of having a single consistent interface for READs might be large enough to adopt this.
That's always been the answer.
SELECT * from redis_db0 limit 5;
other than running the Redis command "KEYS *" - which does a linear scan of the entire Redis keyspace, locking Redis while it does so, and returning every single key in a potentially large streaming response - and truncating to the first 5. (That's fine if you have a few hundred keys, probably not if you have ten million.)I'd love to be contradicted, though :)
Like: SELECT * FROM redis_db0 USING_REDIS limit 5; And Postgres would just pass that"USING_REDIS limit 5" through to Redis? Then Postgres would pass that table or array? back to caller.
Wait, wouldn't this also need modification for DB engine itself?
I've also looked briefly about fdw, as a coworker of mine is trying out mongodb for our level editor... Looked at all implementation and read the every fdw code there (except oracle - as it seems most complex, but for good I guess - it checks the pgsql's AST (is that how it's called?) more deeply).
As for redis, maybe this line is relevant:
https://github.com/dpage/redis_fdw/blob/master/redis_fdw.c#L...
yes, for certain cases (I guess "select ") it does "keys ". I'm also trying out redis for our distributed caching in the studio.
So PostGres is my new favourite thing :) - the fdw looks easy to start, but probably hard to master it.
Then let us welcome you with some pedantry! Postgres or PostgreSQL, but never PostGres or--FSM forbid--PostGreSQL.
More seriously,
> fdw looks easy to start, but probably hard to master it.
Yep, like a number of Postgres features, such as user-defined types and user-defined aggregates. It's a great system, and not nearly as stuffy or hard to use as you may have heard.
Because SQL execution in Postgres (and most other systems) has an advantage of being functional, most executors can save a lot of time avoiding garbage collection and reference management if one is to compare them to, say, Ruby. It's probably going to be faster than bouncing to redis in your application and then to Postgres, for reasons of network overhead.
So, all in all, "it depends", but it should not be slow for a good-quality FDW that pushes down operators well.
Though for the fdws that talk to other SQL based databases, they will pass most of the conditions on to the foreign data source as it is "usually" all just sql.
So the answer is... it depends! :P
edited: I forgot how to write sentences good and stuff