Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL `analyse` vs `analyze`

explain analyse select true;
╔════════════════════════════════════════════════════════════════════════════════════╗
║                                     QUERY PLAN                                     ║
╠════════════════════════════════════════════════════════════════════════════════════╣
║ Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.016..0.016 rows=1 loops=1) ║
║ Planning time: 0.073 ms                                                            ║
║ Execution time: 0.109 ms                                                           ║
╚════════════════════════════════════════════════════════════════════════════════════╝

explain analyze select true;
╔════════════════════════════════════════════════════════════════════════════════════╗
║                                     QUERY PLAN                                     ║
╠════════════════════════════════════════════════════════════════════════════════════╣
║ Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.004..0.005 rows=1 loops=1) ║
║ Planning time: 0.030 ms                                                            ║
║ Execution time: 0.036 ms                                                           ║
╚════════════════════════════════════════════════════════════════════════════════════╝

Is it feature or documented function (analyse = analyze)?

like image 629
Abelisto Avatar asked Dec 03 '16 03:12

Abelisto


People also ask

What is analyze in PostgreSQL?

Description. ANALYZE collects statistics about the contents of tables in the database, and stores the results in the pg_statistic system catalog. Subsequently, the query planner uses these statistics to help determine the most efficient execution plans for queries.

Does analyze really run the query?

EXPLAIN ANALYZE will actually run the query, so be careful with updates or deletes! In those cases, consider not using ANALYZE, or you might perhaps wrap the entire statement in a transaction that you can roll back.

How do you analyze a query in PostgreSQL?

The most powerful tool at our disposal for understanding and optimizing SQL queries is EXPLAIN ANALYZE , which is a Postgres command that accepts a statement such as SELECT ... , UPDATE ... , or DELETE ... , executes the statement, and instead of returning the data provides a query plan detailing what approach the ...


1 Answers

As mentioned it's only to support British vs American English. There is no difference in functionality. Even the source code has a mention of British spelling.

There is also no difference in the timing. If you run those a million times you will not see any reasonable difference in times. Running them once may show some difference, but one is not actually faster than the other.

You can also check the parser source code. Both get parsed into exactly the same:

analyze_keyword:
        ANALYZE                                 {}
        | ANALYSE /* British */                 {}
like image 154
Sami Kuhmonen Avatar answered Oct 19 '22 11:10

Sami Kuhmonen