Database Monitoring and Performance

PostgreSQL provides a good number of catalog tables, views, and extensions to monitor the
instance accurately.

Checking active sessions

Tags:

Turning device-related parameters

PostgreSQL uses several memory components for each unique usage. That is, it uses
dedicated memory areas for transactions, sort/join operations, maintenance operations, and
so on. If the configured memory component doesn't fit the usage of the live application,
then we may hit a performance issue, where PostgreSQL tries for more I/O.

Tags:

Tuning logging-related parameters

The following are the logging-related parameters that usually require tuning:
log_line_prefix
log_statement
log_min_duration_statement

log_line_prefix: Usually the default value related to this parameter is empty and it is
not desirable. A good way to put this in context would be to use the following format:

Tags:

Tuning query-related parameters

The following are the query planning related parameters that usually require tuning:
random_page_cost
seq_page_cost
effective_cache_size
work_mem
constraint_exclusion
These parameters can be set in the postgresql.conf configuration file.

Tags:

Tuning connection-related parameters

These parameters can be set to appropriate values in the postgresql.conf file and these
parameter can be set at server start. The changes made to these parameters will only come
into effect once the PostgreSQL server is restarted, either using the restart mode of the
pg_ctl command or using the stop mode and then followed by the start mode of the
pg_ctl command. This can be done as follows:

Tags:

Avoiding typical mistakes and explicit locking

In this case, there will be either a duplicate key violation or two identical entries. Neither
variation of the problem is all that appealing.

Transaction 1
BEGIN;
SELECT max(id) FROM product;
User will see 17;
User will decide to use 18;
INSERT INTO product ... VALUES (18,
...)
COMMIT;

Transaction 2
BEGIN;
SELECT max(id) FROM product;
User will see 17;
User will decide to use 18;
INSERT INTO product ... VALUES (18,
...)
COMMIT;

Tags:

2. Add Two Numbers

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a linked list.

You may assume the two numbers do not contain any leading zero, except the number 0 itself.

Example

1. absoluteValuesSumMinization

Given a sorted array of integers a, find an integer x from a such that the value of

abs(a[0] - x) + abs(a[1] - x) + ... + abs(a[a.length - 1] - x)
is the smallest possible (here abs denotes the absolute value).
If there are several possible answers, output the smallest one.

**Example**

For a = [2, 4, 7], the output should be
absoluteValuesSumMinimization(a) = 4.

For a = [2, 4, 7, 6], the output should be
absoluteValuesSumMinimization(a) = 4.

1. Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Example

List of HTTP Status Codes

HTTP status codes are like a short note from the web server that gets tacked onto the top of a web page. It’s not actually part of the web page. Instead, it’s a message from the server letting you know how things went when the request to view the page was received by the server.

Pages

Subscribe to Front page feed