dataloader

typescript
import DataLoader from "dataloader";
import { Pool } from "pg";

export interface User { id: number; name: string; }
export interface Post { id: number; user_id: number; title: string; }

N+1 avoidance with DataLoader (GraphQL)

graphql performance dataloader
by codesnips 3 tabs
python
from typing import List, Optional

from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession

from .dataloader import DataLoader

Batched DataLoader to Avoid N+1 Queries in FastAPI Responses

fastapi dataloader n-plus-one
by codesnips 3 tabs
python
import pandas as pd
import torch
from PIL import Image
from torch.utils.data import Dataset, DataLoader

class ProductImageDataset(Dataset):

Custom Datasets and DataLoaders for robust training input pipelines

pytorch dataloader dataset
by Dr. Elena Vasquez 1 tab
ruby
# Gemfile
gem 'graphql'

# Installation
# rails generate graphql:install

GraphQL APIs with graphql-ruby gem

ruby rails graphql
by Sarah Mitchell 3 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
go
package feed

import "time"

type Post struct {
	ID        int64

Batch-Load Related Rows with a Single IN Query to Avoid N+1

go sql postgres
by codesnips 3 tabs
javascript
class BatchLoader {
  constructor(batchFn, { cacheKeyFn = (k) => k } = {}) {
    this.batchFn = batchFn;
    this.cacheKeyFn = cacheKeyFn;
    this.cache = new Map();
    this.queue = [];

Coalescing Concurrent Reads with a DataLoader-Style Batch Loader in Node

dataloader batching graphql
by codesnips 3 tabs