PostgreSQL – Why Use 1-Based Arrays

arraypostgresql

Why is PostgreSQL using 1-based arrays (first element being at index 1) and not 0-based arrays (first element being at index 0)?

Best Answer

While I think Postgresql has had arrays since before SQL-99, the SQL-99 standard specifies 1-indexed arrays, and it's consistent with other areas in SQL where the first element is 1 instead of 0.

PostgreSQL actually has support for custom array start indexes, but I strongly advise you not to use it.