Sample Header Ad - 728x90

Is it possible to have a temporary, on-the-fly PostgreSQL table which only ever lives in RAM?

6 votes
3 answers
12481 views
I know that PostgreSQL automatically uses RAM only for tables that are small enough. But I'm not just talking about the data inside the table, but about the entire table itself. Basically, I've (poorly) re-implemented various database functionality in PHP arrays, for example when I fetch data from an API and want to sort it or "massage" it before displaying it in my control panel. In such a situation, it makes no sense (at least to me) to have an actual database table around which is only ever used for this, with temporary data. It would be much better if I could on-the-fly create a table which I fill up in RAM, sort and then fetch records from with normal PG SQL queries. Is this a thing? It feels stupid that I have array structures and various functions that try to mimic SQL's "SORT BY". Naturally, I'm not talking about executing CREATE TABLE, add the data to it, and then return it again to PHP, and then DROP TABLE. That would be ridiculously bad for performance. If there is no way to do this, I'll just accept it, but it's something which I've often thought would make perfect sense.
Asked by user15080516 (745 rep)
Feb 10, 2021, 03:10 AM
Last activity: May 6, 2024, 10:45 AM