Is array_append O(n)? - Mailing list pgsql-general

From Rob Nikander
Subject Is array_append O(n)?
Date
Msg-id D8BF133C-3C50-4A1C-B7F7-E5F27A776673@gmail.com
Whole thread Raw
Responses Re: Is array_append O(n)?
List 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
useplpgsql 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
withlittle cost (O(1), almost.) 

Rob


pgsql-general by date:

Previous
From: Andres Freund
Date:
Subject: Re: perf tuning for 28 cores and 252GB RAM
Next
From: Miles Elam
Date:
Subject: Re: Inserts restricted to a trigger