Is array_append O(n)?

From: Rob Nikander <rob(dot)nikander(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Is array_append O(n)?
Date: 2019-06-18 16:20:39
Message-ID: D8BF133C-3C50-4A1C-B7F7-E5F27A776673@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

Does `array_append(arr, elt)` create a new array and copy everything? In other words, is it O(n) or O(1)? I’m trying to use plpgsql and realizing I don’t really have my usual data structures for basic algorithms the way I’d normally write them. I probably shouldn’t be treating arrays like Java ArrayList or C++ vector, where you can add/remove on the end with little cost (O(1), almost.)

Rob

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Miles Elam 2019-06-18 16:30:12 Re: Inserts restricted to a trigger
Previous Message Andres Freund 2019-06-18 16:18:02 Re: perf tuning for 28 cores and 252GB RAM