StartUp Costs Postgresql Debugging

In the mission on debugging postgres queries, it mentions startup and total costs, but it doesn’t explained them very well. It just states that startup costs are the time it takes before a row can be returned. What exactly does it mean by ‘before a row can be returned’ ? With a simple “EXPLAIN SELECT * FROM TABLE;” example, there needs to only be a seq scan, but how does it determine that there are 0 startup costs? Doesn’t it take time to loop through all row in a table, or does startup costs only measure the time that it takes to preprocess any rows? Does the measuring of startup cost begin after the seq scans are done? Please help. Thanks.

Hi @tyrantula767: Please provide a question link and format your code accordingly as per these guidelines so that we can better assist you.

In the mission on debugging postgres queries, it mentions startup and total costs, but it doesn’t explained them very well. It just states that startup costs are the time it takes before a row can be returned. What exactly does it mean by ‘before a row can be returned’ ? With a simple sql EXPLAIN SELECT * FROM TABLE; example, there needs to only be a seq scan, but how does it determine that there are 0 startup costs? Doesn’t it take time to loop through all row in a table, or does startup costs only measure the time that it takes to preprocess any rows? Does the measuring of startup cost begin after the seq scans are done? Please help. Thanks.

Data Engineering: Debugging Postgres Queries

Hi @tyrantula767,

The startup cost is the cost before rows start to be collected. It counts all to work that needs to be done before actually starting to answer the query. This time depends on the strategy used to answer it. You can imagine a sequential scan as a for loop over the rows. Looping over data does not require any kind of computation before we can start doing it so the cost is 0.

Some other queries might require the data to be sorted before we can start collecting the results. In this case the sorting cost would be part of the startup cost.

1 Like