Maximum number of columns in a table? 250-1600 depending on column types
Maximum number of indexes on a table? unlimited
+
Of course, these are not actually unlimited, but limited to
available disk space and memory/swap space. Performance may suffer
when these values get unusually large.
When using wild-card operators such as LIKE or
- ~, indexes can only be used if the default C local is used
-during initdb and the beginning of the search
- is anchored to the start of the string. Therefore, to use indexes,
- LIKE patterns must not start with %, and
- ~(regular expression) patterns must start with ^.
+ ~, indexes can only be used in certain circumstances:
+
The beginning of the search string must be anchored to the start
+ of the string, i.e.:
+
LIKE patterns must not start with %.
+
~(regular expression) patterns must start with
+ ^.
+
+
The search string can not start with a character class,
+ e.g. [a-e].
+
Case-insensitive searches like ILIKE and
+ ~* can not be used. Instead, use functional
+ indexes, which are described later in this FAQ.
+
The default C local must have been used during
+ initdb.
+
4.9) How do I see how the query optimizer is
evaluating my query?
SELECT *
FROM tab
WHERE lower(col) = 'abc'
-
+
This will not use an standard index. However, if you create a
functional index, it will be used:
CREATE INDEX tabindex on tab (lower(col));
-
4.13) In a query, how do I detect if a field
name TEXT
);
+
is automatically translated into this:
CREATE SEQUENCE person_id_seq;
);
CREATE UNIQUE INDEX person_id_key ON person ( id );
+
See the create_sequence manual page for more information
about sequences. You can also use each row's OID field as a
unique value. However, if you need to dump and reload the database,
new_id = output of "SELECT nextval('person_id_seq')"
INSERT INTO person (id, name) VALUES (new_id, 'Blaise Pascal');
+
You would then also have the new value stored in
new_id
for use in other queries (e.g., as a foreign
key to the person
table). Note that the name of the
INSERT INTO person (name) VALUES ('Blaise Pascal');
new_id = output of "SELECT currval('person_id_seq')";
+
Finally, you could use the
OID
returned from the INSERT statement to look up the
default value, though this is probably the least portable approach.
ulimit -d 262144
limit datasize 256m
+
Depending on your shell, only one of these may succeed, but it will
set your process data segment limit much higher and perhaps allow
the query to complete. This command applies to the current process,
WHERE EXISTS (SELECT col2 FROM TAB2 WHERE col1 = col2)
+
We hope to fix this limitation in a future release.
4.23) How do I perform an outer join?