Posts

Showing posts with the label database performance

Overhead in PostgreSQL

Image
Introduction In computer science and systems engineering, overhead is not a bug, but it is a phenomenon of system resource waste. Overhead is the amount of time, memory, bandwidth or CPU power consumed to manage or operate the system, rather than contributing directly to the actual data processing results. In database management systems, overhead occurs very frequently. Especially, if the system suffers from excessive memory (RAM) overhead, the Operating System (OS) will trigger a mechanism to kill that process to save the server. Common Types of Overhead in Postgres Postgres has a process-based architecture, meaning each client connection generates an independent process, so it easily encounters the following types of overhead: Connection Overhead: If you have 500 concurrent connections, Postgres will create 500 processes. The fact that the CPU must constantly context switch among these 500 processes creates a massive amount of overhead, significantly reducing performance. Memory Over...

Partial Index

Image
Introduction Partial Index is an extremely powerful feature that allows the creation of an index on only a subset of a table's data, instead of indexing the entire table. This subset is defined by a filtering condition in a WHERE clause when creating the index. In essence, a Partial Index just adds a condition during index creation, so it can be used with all index types (such as B-Tree , Hash , GIN , GiST , ...) and supports all data types. Additionally, a Partial Index can also be used in combination with a Constraint , Expression Index and Composite Index . Advantages Space-saving: The index size is much smaller than a Full Index, which saves RAM and disk space. Increased Write performance (INSERT/UPDATE/DELETE): When adding or modifying data that does not satisfy the index condition, Postgres does not need to update the index tree. Disadvantages Queries must match the condition: The Postgres Query Planner only uses this index if the SELECT query has a WHERE clause that exactl...