Performance Tips

Optimize your NexaDB applications for maximum performance.

Use Binary Protocol

13x Faster

Always use the official client libraries (nexaclient for JavaScript, nexadb for Python) which automatically use the binary protocol. Avoid using the HTTP REST API in production.

✓ const db = new NexaClient({ port: 6970 })
✗ fetch('http://localhost:6970/api/...')

Connection Pooling

Reuse Connections
// Create ONE connection at app startup
const db = new NexaClient({
  host: 'localhost',
  port: 6970,
  username: 'root',
  password: 'nexadb123'
});
await db.connect();

// Reuse the same connection for all requests
app.get('/users/:id', async (req, res) => {
  const user = await db.get('users', req.params.id);
  res.json(user);
});

// Don't create new connections per request!
// ✗ const db = new NexaClient(); await db.connect();

Batch Operations

8x Faster

Use batch operations when creating, updating, or deleting multiple documents. This reduces network overhead significantly.

✓ await db.batchCreate('users', [user1, user2, ...])
✗ await Promise.all(users.map(u => db.create('users', u)))

Query Optimization

Use Limits

Always specify a limit to avoid returning too many documents.

await db.query('users', {}, { limit: 100 })

Index Frequently Queried Fields

Create indexes on fields you query often for faster lookups.

await db.createIndex('users', 'email')

Select Specific Fields

Only retrieve the fields you need to reduce data transfer.

await db.query('users', {}, { fields: ['name', 'email'] })

Memory Management

In-Memory Performance

NexaDB keeps frequently accessed data in memory for ultra-fast access. With just 111MB memory footprint, you can handle millions of operations efficiently.

89K/s
Write ops
0.05ms
Read latency
111MB
Memory usage

Best Practices

✓ Do
  • • Use binary protocol clients
  • • Reuse connections
  • • Use batch operations
  • • Set query limits
  • • Create indexes on common queries
✗ Don't
  • • Use HTTP API in production
  • • Create connections per request
  • • Query without limits
  • • Fetch unnecessary fields
  • • Skip batch operations