Why is postgreSQL using 1-based arrays?

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

Answers 1

  • 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.

Related Questions