Menu

Post image 1
Post image 2
1 / 2
0

Where Does a Query Go?

DEV Community·JoongHyuk Shin·29 days ago
#bBWgdX5b
Reading 0:00
15s threshold

Suppose a client sends SELECT * FROM users WHERE id = 1 . The path that single line travels before coming back as a result row is longer than you might expect. Inside the PostgreSQL backend, that SQL goes through a five-stage pipeline. Backend entry and dispatch . The backend receives the message from the client and decides which processing path it should follow. Parser and Analyzer . The SQL text is parsed, and the catalog is consulted to give it meaning. Rewriter . The RULE system expands views, injects RLS policies, and otherwise transforms the query tree. Planner . Using a cost model, it explores possible execution paths and picks the best one. Executor . It walks the chosen plan, pulling tuples up and sending them to the client. Chapter 1 of this book unfolds this pipeline one chapter at a time. The chapter you're reading now covers stage 1: the entry point. It has three sections.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More