DEV Community

Discussion on: The What and Why of PostgreSQL Views

Collapse
 
daniel15 profile image
Daniel Lo Nigro

Great video! I like how you mentioned that it "feels right". That's really a huge part of application design - The best design patterns often just feel like the right thing to do.

The other thing that you didn't mention is that when using SQL views, the database engine can do some pre-optimization of the query, as it knows the exact query that's going to be ran. This can result in a small performance boost for very common queries. With a regular query, it needs to parse, prepare, and optimize that query every single time you run it.

Collapse
 
annarankin profile image
Anna Rankin

Oh, cool - I actually didn't know that! Thanks :D

Collapse
 
buinauskas profile image
Evaldas Buinauskas

That's partially true. For instance SQL Server cashes parameterized queries and saves their execution plans.

At least to my knowledge 🙂