{
    "url": "https://delaparra-services.nl/knowledge-hub/composite-index",
    "locale": "en",
    "title": "composite index: Knowledge hub | DeLaParra Services",
    "description": "An index on multiple columns. Order matters — it can serve queries that use a leftmost prefix of the columns.",
    "alternates": {
        "en": "https://delaparra-services.nl/knowledge-hub/composite-index",
        "nl": "https://delaparra-services.nl/nl/kennisbank/composite-index"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/knowledge-hub/composite-index.csv",
        "md": "https://delaparra-services.nl/knowledge-hub/composite-index.md",
        "json": "https://delaparra-services.nl/knowledge-hub/composite-index.json",
        "zip": "https://delaparra-services.nl/knowledge-hub/composite-index.zip",
        "pdf": "https://delaparra-services.nl/knowledge-hub/composite-index.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/knowledge-hub/composite-index.csv",
            "encodingFormat": "text/csv",
            "name": "composite-index.csv"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/composite-index.json",
            "encodingFormat": "application/json",
            "name": "composite-index.json"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/composite-index.md",
            "encodingFormat": "text/markdown",
            "name": "composite-index.md"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/composite-index.pdf",
            "encodingFormat": "application/pdf",
            "name": "composite-index.pdf"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/composite-index.zip",
            "encodingFormat": "application/zip",
            "name": "composite-index.zip"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/composite-index/skills.zip",
            "encodingFormat": "application/zip",
            "name": "composite-index-skills.zip"
        }
    ],
    "markdown": "1. [Home](<https://delaparra-services.nl/>) \n1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) \n1. [composite index](<https://delaparra-services.nl/knowledge-hub/composite-index>)\n\n  \n\nCategory: SQL \n\n# composite index\n\n  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    \n\n## What is composite index?\n\n \n\ncomposite index: An index on multiple columns. Order matters — it can serve queries that use a leftmost prefix of the columns. A composite index covers several columns, such as ` (customer_id, created_at) `. The database sorts by the first column, then by the second within each value of the first. The order of columns is everything. This index helps a query that filters on ` customer_id `, or on ` customer_id ` and ` created_at ` together. It does not help a query that only filters on ` created_at `, just as a phone book sorted by surname does not help you find everyone named Jan.\n\n \n\nDefinition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)\n\n \n\n## Frequently asked questions about composite index\n\n  \n\n### What should you keep in mind with composite index?\n\n \n\nPut the column used for exact matches first and the range or sort column last. One well-chosen composite index can replace several single-column indexes and speed up common queries like \"this customer's latest orders\". Use ` EXPLAIN ` to check which index a query really uses.\n\n    \n\n### What does an example of composite index look like?\n\n \n\n```\nCREATE INDEX idx_orders_user_date ON orders (user_id, created_at);\n```\n\n \n\n## At a glance\n\n   CategorySQL Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026\n\n \n\n## More SQL terms\n\n \n\n- [BEGIN / COMMIT / ROLLBACK](<https://delaparra-services.nl/knowledge-hub/begin-commit-rollback>) \n- [CASE](<https://delaparra-services.nl/knowledge-hub/case>) \n- [COALESCE](<https://delaparra-services.nl/knowledge-hub/coalesce>) \n- [COUNT / SUM / AVG / MIN / MAX](<https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max>) \n- [covering index](<https://delaparra-services.nl/knowledge-hub/covering-index>) \n- [CROSS JOIN](<https://delaparra-services.nl/knowledge-hub/cross-join>)\n\n \n\n[All terms starting with C](<https://delaparra-services.nl/knowledge-hub#letter-c>)\n\n \n\n## Skills\n\n \n\n- ### SQL Performance Optimization Assistant\n\n \n\n'Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Provides execution plan analysis, pagination optimization, batch operations, and performance monitoring guidance.'\n\n [View skill](<https://delaparra-services.nl/skills/sql-optimization>) [Download zip](<https://delaparra-services.nl/skills/sql-optimization/download>) \n- ### SQL Optimization Patterns\n\n \n\nMaster SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.\n\n [View skill](<https://delaparra-services.nl/skills/sql-optimization-patterns>) [Download zip](<https://delaparra-services.nl/skills/sql-optimization-patterns/download>) \n- ### Supabase Postgres Best Practices\n\n \n\nPostgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and schedule\n\n [View skill](<https://delaparra-services.nl/skills/supabase-postgres-best-practices>) [Download zip](<https://delaparra-services.nl/skills/supabase-postgres-best-practices/download>)\n\n [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/composite-index/skills.zip>)\n\n \n\n## Manuals\n\n \n\n- [Writing SQL queries and migrations](<https://delaparra-services.nl/manuals/sql-queries-en-migraties>)\n\n \n\n## Related services\n\n \n\n- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)\n\nPerhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet. \n- [AI code review](<https://delaparra-services.nl/services#service-05>)\n\nWhen you push your new change, I will review your code, help your agent avoid the same mistake again, and get your app ready for deployment.\n\n \n\n## Need any help?\n\n \n\nStuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.\n\n  [Get in touch](<https://delaparra-services.nl/availability>)\n\n[HTML version](https://delaparra-services.nl/knowledge-hub/composite-index)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "FAQPage",
                "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#webpage",
                "url": "https://delaparra-services.nl/knowledge-hub/composite-index",
                "name": "composite index: Knowledge hub | DeLaParra Services",
                "description": "An index on multiple columns. Order matters — it can serve queries that use a leftmost prefix of the columns.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@type": "DefinedTerm",
                    "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#term",
                    "name": "composite index",
                    "description": "An index on multiple columns. Order matters — it can serve queries that use a leftmost prefix of the columns.",
                    "termCode": "composite-index",
                    "url": "https://delaparra-services.nl/knowledge-hub/composite-index",
                    "inLanguage": "en",
                    "keywords": "SQL",
                    "dateModified": "2026-11-25T17:46:25+00:00",
                    "inDefinedTermSet": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#terms"
                    },
                    "isPartOf": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#dataset"
                    },
                    "subjectOf": [
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#webpage"
                        },
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#dataset"
                        }
                    ]
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#breadcrumb"
                },
                "mainEntity": [
                    {
                        "@type": "Question",
                        "name": "What is composite index?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "An index on multiple columns. Order matters — it can serve queries that use a leftmost prefix of the columns. A composite index covers several columns, such as (customer_id, created_at). The database sorts by the first column, then by the second within each value of the first. The order of columns is everything. This index helps a query that filters on customer_id, or on customer_id and created_at together. It does not help a query that only filters on created_at, just as a phone book sorted by surname does not help you find everyone named Jan."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What should you keep in mind with composite index?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Put the column used for exact matches first and the range or sort column last. One well-chosen composite index can replace several single-column indexes and speed up common queries like \"this customer's latest orders\". Use EXPLAIN to check which index a query really uses."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What does an example of composite index look like?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "CREATE INDEX idx_orders_user_date ON orders (user_id, created_at);"
                        }
                    }
                ],
                "author": {
                    "@id": "https://delaparra-services.nl/#person"
                },
                "mentions": [
                    {
                        "@id": "https://delaparra-services.nl/skills/sql-optimization#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/sql-optimization-patterns#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/supabase-postgres-best-practices#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/manuals/sql-queries-en-migraties#article"
                    }
                ]
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Knowledge hub",
                        "item": "https://delaparra-services.nl/knowledge-hub"
                    },
                    {
                        "@type": "ListItem",
                        "position": 3,
                        "name": "composite index"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#dataset",
                "name": "composite index",
                "description": "An index on multiple columns. Order matters — it can serve queries that use a leftmost prefix of the columns.",
                "url": "https://delaparra-services.nl/knowledge-hub/composite-index",
                "identifier": "https://delaparra-services.nl/knowledge-hub/composite-index#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/composite-index#term"
                },
                "creator": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://creativecommons.org/licenses/by/4.0/",
                "creditText": "Coders Lingo (https://coderslingo.com/resources/open-dataset/), CC BY 4.0",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "keywords": "SQL",
                "version": "2026-11-25",
                "dateModified": "2026-11-25T17:46:25+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#dataset",
                    "name": "IT terms from A to Z",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "composite-index.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/composite-index.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "composite-index.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/composite-index.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "composite-index.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/composite-index.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "composite-index.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/composite-index.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "composite-index.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/composite-index.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "composite-index-skills.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/composite-index/skills.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    }
                ]
            }
        ]
    }
}