Junior — Middle
Describe your experience with using and configuring PostgreSQL, as well as the features of working with this database.
sobes.tech AI
Answer from AI
In my experience with PostgreSQL, I have configured databases for Node.js applications using the popular pg package for connection and query execution. The setup included creating users with appropriate permissions, optimizing configuration parameters (such as work_mem, shared_buffers) to improve performance, and setting up indexes to speed up queries.
Features of PostgreSQL:
- Support for complex data types (JSON, arrays, geospatial data).
- Powerful transaction system supporting ACID.
- Extensibility through plugins and user-defined functions.
Example of connection and query in Node.js:
const { Pool } = require('pg');
const pool = new Pool({
user: 'user',
host: 'localhost',
database: 'mydb',
password: 'password',
port: 5432,
});
async function getUsers() {
const res = await pool.query('SELECT * FROM users');
return res.rows;
}
getUsers().then(console.log).catch(console.error);
It is also important to monitor security — use SSL, restrict access by IP, and regularly back up.