Bird
0
0

Why is it important to CLOSE a cursor after use in PostgreSQL?

hard📝 Conceptual Q10 of 15
PostgreSQL - Advanced PL/pgSQL
Why is it important to CLOSE a cursor after use in PostgreSQL?
ATo automatically commit transactions
BTo delete the underlying table
CTo release resources and avoid memory leaks
DTo reset the database connection
Step-by-Step Solution
Solution:
  1. Step 1: Understand cursor resource usage

    Cursors hold server resources like memory and locks while open.
  2. Step 2: Importance of closing

    Closing a cursor frees these resources to prevent leaks and improve performance.
  3. Final Answer:

    To release resources and avoid memory leaks -> Option C
  4. Quick Check:

    Closing cursor = free resources [OK]
Quick Trick: Always CLOSE cursors to free resources [OK]
Common Mistakes:
  • Thinking CLOSE commits transactions
  • Assuming CLOSE deletes tables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes