performance

ruby
# Gemfile
group :development do
  gem 'rack-mini-profiler'
  gem 'memory_profiler'
  gem 'stackprof'  # For flamegraphs
  gem 'bullet'     # N+1 detection

Performance profiling with rack-mini-profiler and tools

ruby rails performance
by Sarah Mitchell 2 tabs
python
from blog.models import Post


# Load only specific fields
posts = Post.objects.only('id', 'title', 'published_at')
for post in posts:

Django query optimization with only and defer

django python database
by Priya Sharma 1 tab
javascript
import { useEffect, useState } from "react";

export function useDebouncedValue(value, delay = 300) {
  const [debounced, setDebounced] = useState(value);

  useEffect(() => {

Debounced Search Input in React with a Reusable useDebouncedValue Hook

react hooks debounce
by codesnips 3 tabs
python
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'mydb',
        'USER': 'myuser',
        'PASSWORD': 'mypassword',

Django database connection pooling for performance

django python database
by Priya Sharma 1 tab
python
# Debug Toolbar setup
INSTALLED_APPS += ['debug_toolbar']

MIDDLEWARE = [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
] + MIDDLEWARE

Django debug toolbar for development

django python debugging
by Priya Sharma 1 tab
ruby
class ActivityPanelController < ApplicationController
  def show
    @project = Project.find(params[:project_id])
    @events = @project.events.order(created_at: :desc).limit(50)

    latest = @events.maximum(:updated_at)

ETag + last_modified for expensive Turbo Frame endpoints

rails hotwire turbo
by Henry Kim 2 tabs
typescript
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

export async function getFeedNaive(limit = 20) {
  const posts = await prisma.post.findMany({

Prisma: avoid N+1 with include/select

prisma performance typescript
by codesnips 3 tabs
rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn fibonacci(n: u64) -> u64 {
    match n {
        0 => 1,
        1 => 1,

Criterion for benchmarking with statistical analysis

rust benchmarking performance
by Marcus Chen 1 tab
yaml
production:
  primary:
    adapter: postgresql
    database: app_production
    username: app
    password: <%= ENV["PRIMARY_DB_PASSWORD"] %>

Read Replica Routing for GET-Heavy Endpoints

rails activerecord postgres
by codesnips 4 tabs
sql
-- INNER JOIN: Only matching rows
SELECT
  users.name,
  orders.order_number,
  orders.total
FROM users

Advanced SQL joins and query optimization

sql joins query-optimization
by Maria Garcia 2 tabs
typescript
import { FixedSizeList as List } from 'react-window'
import AutoSizer from 'react-virtualized-auto-sizer'
import { Post } from '@/types'
import { PostCard } from './PostCard'

interface VirtualizedPostListProps {

Virtual scrolling for large lists with react-window

react performance virtual-scrolling
by Maya Patel 1 tab
ruby
# In rails console
query = Post.joins(:author)
           .where(published_at: 1.week.ago..Time.current)
           .where(users: { status: 'active' })
           .order(created_at: :desc)

Database query explain analysis for optimization

rails postgresql performance
by Alex Kumar 2 tabs