Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add infrastructure for chosing index methods initial support for postgresql #469

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

salacr
Copy link
Contributor

@salacr salacr commented Mar 18, 2023

Most DB engines (at least Postgresql, MySQL, ORacle . SQLServer) support different index methods.
For Oracle, and SQLServer the syntax is more complicated but it's out of the scope infrastructure should be the same.

@@ -393,10 +393,11 @@ function indexes($table, $connection2 = null) {
$return = array();
$table_oid = $connection2->result("SELECT oid FROM pg_class WHERE relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema()) AND relname = " . q($table));
$columns = get_key_vals("SELECT attnum, attname FROM pg_attribute WHERE attrelid = $table_oid AND attnum > 0", $connection2);
foreach (get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption, (indpred IS NOT NULL)::int as indispartial FROM pg_index i, pg_class ci WHERE i.indrelid = $table_oid AND ci.oid = i.indexrelid", $connection2) as $row) {
foreach (get_rows("SELECT relname, indisunique::int, indisprimary::int, indkey, indoption, (indpred IS NOT NULL)::int as indispartial, am.amname as method FROM pg_index i, pg_class ci, pg_am am WHERE i.indrelid = $table_oid AND am.oid = ci.relam AND ci.oid = i.indexrelid ORDER BY indisprimary DESC", $connection2) as $row) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small piggyback, primary index should be the first in table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant