1

I am using postgres 9.5.4 configured as cluster using citus 5.2

The table has been sharded using below commands.

SELECT master_create_distributed_table('mytest', 'id', 'hash');
SELECT master_create_worker_shards('mytest', 16, 1);

From below sample json data stored in jsonb column, I would like to search records matching

o['mid'] > 7000

This is sample of one user's record. There will be millions of such users.

{   "uid": 14105529,   "o": [
    {
      "mid": 6551,
       "ac": 1913,
       "ip": "144.36.233.44",
       "adw": 5,
       "at": 133000,
       "ad": 151015,
       "aid": 0
     },
     {
       "mid": 7552,
       "ac": 1913,
       "ip": "144.36.233.44",
       "adw": 5,
       "at": 133000,
       "ad": 151015,
       "aid": 0
     },
     {
       "mid": 7553,
       "ac": 1913,
       "ip": "144.36.233.44",
       "adw": 5,
       "at": 133000,
       "ad": 151015,
       "aid": 0
    }   ] 
}

The below query throws error, where as it executes on un-sharded table.

select count(1) from mytest,jsonb_array_elements(data->'l') where (value->>'e')::bigint>7000;

ERROR: cannot perform distributed planning on this query

DETAIL: Complex table expressions are currently unsupported

1 Answer 1

3

jsonb_array_elements(data->'l') is causing a CTE to be created which causes this query to get rejected, could you re-write your query to avoid joins ?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.