From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andreas Brandl <ml(at)3(dot)141592654(dot)de> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Array access performance |
Date: | 2011-08-02 14:49:41 |
Message-ID: | 19283.1312296581@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Andreas Brandl <ml(at)3(dot)141592654(dot)de> writes:
> I'm looking for a hint how array access performs in PostgreSQL in respect to performance. Normally I would expect access of a 1-dimensional Array at slot i (array[i]) to perform in constant time (random access).
> Is this also true for postgres' arrays?
Only if the element type is fixed-length (no strings for instance) and
the array does not contain, and never has contained, any nulls.
Otherwise a scan through all the previous elements is required to find
a particular element.
By and large, if you're thinking of using arrays large enough to make
this an interesting question, I would say stop right there and redesign
your database schema. You're not thinking relationally, and it's gonna
cost ya.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Brandl | 2011-08-02 15:16:09 | Re: Array access performance |
Previous Message | Andreas Brandl | 2011-08-02 13:11:52 | Re: Array access performance |