Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Postgres explan analyse not working with alter table

I’m trying to alter the type of a column from a table but I also want to know how long it takes to alter the table. I therefore combined:

EXPLAIN ANALYSE

command with:

ALTER TABLE tbl_name ALTER COLUMN col_name TYPE new_type;

So I did:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

EXPLAIN ANALYSE ALTER TABLE my_table ALTER COLUMN my_column TYPE text;

But I get the error:

ERROR:  syntax error at or near "ALTER"
LINE 1: EXPLAIN ANALYSE ALTER TABLE my_table ALTER COLUMN my_column...
                        ^

But when I EXPLAIN ANALYSE with a SELECT it has no problem.

ie:

explain analyse select * from my_column limit 300;

I must be missing something really simple but I’m not seeing it?

>Solution :

The manual for EXPLAIN:

Any SELECT, INSERT, UPDATE, DELETE, VALUES, EXECUTE, DECLARE, CREATE TABLE AS, or CREATE MATERIALIZED VIEW AS statement, whose execution plan you wish to see.

ALTER TABLE is not covered.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading