-- Basic EXPLAIN
EXPLAIN
SELECT * FROM users WHERE email = 'alice@example.com';
-- EXPLAIN with cost and row estimates
-- Output shows: Seq Scan on users (cost=0.00..15.50 rows=1 width=100)
from django.db.models import Prefetch
from django.views.generic import ListView
from .models import Post, Comment
class PostListView(ListView):
class AddCommentsCountToPosts < ActiveRecord::Migration[6.1]
def up
add_column :posts, :comments_count, :integer, default: 0, null: false
# Populate existing counts
Post.find_each do |post|
<%# Fragment caching - caches rendered HTML %>
<% cache @product do %>
<h1><%= @product.name %></h1>
<p><%= @product.description %></p>
<p>Price: $<%= @product.price %></p>
<% end %>
class CreateCustomerRevenueSummaries < ActiveRecord::Migration[7.0]
def change
create_view :customer_revenue_summaries, materialized: true, version: 1
add_index :customer_revenue_summaries,
:customer_id,
-- Create basic index
CREATE INDEX idx_users_email ON users(email);
-- Unique index (enforces uniqueness)
CREATE UNIQUE INDEX idx_users_username ON users(username);
CREATE TABLE subscriptions (
id BIGGENERATED ALWAYS AS IDENTITY PRIMARY KEY,
customer_id BIGINT NOT NULL,
plan_code TEXT NOT NULL,
status TEXT NOT NULL DEFAULT 'active',
current_period_end TIMESTAMPTZ NOT NULL,
import { SetMetadata } from '@nestjs/common';
export const CACHEABLE_KEY = 'cacheable:options';
export type VaryDimension = 'user' | 'tenant' | 'query';
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["sentinel"]
static values = {
url: String
import { Link } from 'react-router-dom'
import { useQueryClient } from '@tanstack/react-query'
import api from '@/services/api'
import { PostId } from '@/types'
interface PostLinkProps {
import React from 'react'
interface SkeletonProps {
width?: string | number
height?: string | number
className?: string
module KeysetPaginatable
extend ActiveSupport::Concern
class_methods do
def keyset_page(cursor: nil, limit: 20, direction: :desc)
limit = limit.to_i.clamp(1, 100)