[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"content:legacy:page:\u002Finterviews\u002Fsql-databases":3,"content:legacy:surround:\u002Finterviews\u002Fsql-databases":221,"content:legacy:navigation":230},{"id":4,"title":5,"body":6,"description":208,"extension":209,"icon":210,"meta":211,"modifiedAt":212,"navigation":213,"path":214,"publishedAt":215,"seo":216,"sitemap":217,"stem":218,"updatedAt":219,"__hash__":220},"interviews\u002Finterviews\u002Fsql-databases.md","SQL and Databases",{"type":7,"value":8,"toc":206},"minimark",[9,32,50,80,98,116,134,152,170,188],[10,11,12,23],"collapsible",{},[13,14,16],"template",{"v-slot:title":15},"",[17,18,19],"ol",{},[20,21,22],"li",{},"What trade-offs do indexes introduce?",[13,24,25,29],{"v-slot:content":15},[26,27,28],"p",{},"An index can reduce reads by providing an ordered access path, but consumes storage and adds maintenance work to inserts, updates, and deletes. Too many overlapping indexes increase write amplification and planning complexity.",[26,30,31],{},"Design indexes from actual query predicates, joins, ordering, and selectivity, then verify them with execution plans and production-like data.",[10,33,34,42],{},[13,35,36],{"v-slot:title":15},[17,37,39],{"start":38},2,[20,40,41],{},"Why does column order matter in a composite index?",[13,43,44,47],{"v-slot:content":15},[26,45,46],{},"A composite index is ordered by its leading columns. Queries that constrain the prefix can usually use it efficiently; skipping the leading column often limits its usefulness.",[26,48,49],{},"Put equality predicates and common access patterns first, then range or ordering columns as appropriate. The correct order depends on workload, selectivity, and the database engine's optimizer.",[10,51,52,60],{},[13,53,54],{"v-slot:title":15},[17,55,57],{"start":56},3,[20,58,59],{},"Explain ACID properties.",[13,61,62,77],{"v-slot:content":15},[63,64,65,68,71,74],"ul",{},[20,66,67],{},"Atomicity: a transaction commits all intended changes or none.",[20,69,70],{},"Consistency: committed data respects defined invariants.",[20,72,73],{},"Isolation: concurrent transactions behave according to the chosen isolation guarantees.",[20,75,76],{},"Durability: committed changes survive expected failures.",[26,78,79],{},"ACID does not automatically make application workflows correct; constraints and transaction boundaries still need careful design.",[10,81,82,90],{},[13,83,84],{"v-slot:title":15},[17,85,87],{"start":86},4,[20,88,89],{},"What anomalies can isolation levels permit?",[13,91,92,95],{"v-slot:content":15},[26,93,94],{},"Depending on the database and isolation level, transactions may observe dirty reads, non-repeatable reads, phantoms, or write skew. Stronger isolation reduces possible anomalies but can increase waiting, aborts, or coordination.",[26,96,97],{},"Choose isolation from the business invariant, not only performance assumptions, and implement safe retry handling for serialization failures or deadlocks.",[10,99,100,108],{},[13,101,102],{"v-slot:title":15},[17,103,105],{"start":104},5,[20,106,107],{},"How do optimistic and pessimistic locking differ?",[13,109,110,113],{"v-slot:content":15},[26,111,112],{},"Optimistic concurrency detects conflicts at write time, often with a version column, and works well when conflicts are uncommon. Pessimistic locking acquires locks before a conflicting operation proceeds and suits short critical sections with higher contention.",[26,114,115],{},"Both require bounded transactions and clear retry or timeout behavior.",[10,117,118,126],{},[13,119,120],{"v-slot:title":15},[17,121,123],{"start":122},6,[20,124,125],{},"What does an execution plan tell you?",[13,127,128,131],{"v-slot:content":15},[26,129,130],{},"It shows the operations selected by the optimizer: scans, index lookups, join algorithms, sorts, estimated rows, and costs. An analyzed plan can compare estimates with actual rows and timing.",[26,132,133],{},"Large estimate errors often point to stale statistics, correlated data, or expressions the optimizer cannot model well. Tune the query or schema based on evidence rather than forcing an index blindly.",[10,135,136,144],{},[13,137,138],{"v-slot:title":15},[17,139,141],{"start":140},7,[20,142,143],{},"Normalization versus denormalization: when would you choose each?",[13,145,146,149],{"v-slot:content":15},[26,147,148],{},"Normalization reduces duplication and update anomalies by representing each fact once with explicit relationships. Denormalization duplicates or precomputes data to make important reads simpler or faster.",[26,150,151],{},"Start with a coherent normalized model, measure bottlenecks, and denormalize deliberately with a defined owner and consistency strategy.",[10,153,154,162],{},[13,155,156],{"v-slot:title":15},[17,157,159],{"start":158},8,[20,160,161],{},"What is the N+1 query problem?",[13,163,164,167],{"v-slot:content":15},[26,165,166],{},"The application loads a list with one query, then issues another query for each row's related data. Latency and database work grow with the result size.",[26,168,169],{},"Fix it with an appropriate join, batch loading, prefetching, or a data-loader pattern. Do not fetch an unbounded object graph merely to avoid query count.",[10,171,172,180],{},[13,173,174],{"v-slot:title":15},[17,175,177],{"start":176},9,[20,178,179],{},"How should database migrations be deployed safely?",[13,181,182,185],{"v-slot:content":15},[26,183,184],{},"Use backward-compatible expand-and-contract steps: add the new schema, deploy code that can work during transition, backfill in bounded batches, switch reads or writes, then remove the old schema later.",[26,186,187],{},"Avoid long blocking changes during peak traffic, observe progress, and prepare a recovery strategy that does not depend on instantly reversing a destructive migration.",[10,189,190,198],{},[13,191,192],{"v-slot:title":15},[17,193,195],{"start":194},10,[20,196,197],{},"When are replicas and partitions useful?",[13,199,200,203],{"v-slot:content":15},[26,201,202],{},"Read replicas can scale reads and improve availability, but asynchronous replication introduces lag and read-after-write concerns. Partitioning splits data by a key to reduce per-node size or load, but cross-partition operations become harder.",[26,204,205],{},"Choose routing keys from access patterns and growth estimates, and plan how hotspots, rebalancing, backups, and failover will work.",{"title":15,"searchDepth":38,"depth":38,"links":207},[],"Database interview questions about indexes, transactions, query plans, schema design, and data consistency.","md","lucide:database",{},null,true,"\u002Finterviews\u002Fsql-databases","2026-09-21",{"title":5,"description":208},{"loc":214,"lastmod":215},"interviews\u002Fsql-databases","2026-09-21T22:49:35+07:00","gNuK-mRTTBd91cA8sg7DJUVjE2ujJRW7fTLfho4dhC0",[222,226],{"title":223,"path":224,"stem":225,"children":-1},"Software Testing","\u002Finterviews\u002Fsoftware-testing","interviews\u002Fsoftware-testing",{"title":227,"path":228,"stem":229,"children":-1},"System Design","\u002Finterviews\u002Fsystem-design","interviews\u002Fsystem-design",[231,382,490,505],{"title":232,"icon":233,"path":234,"stem":235,"children":236,"page":247},"Posts","fluent-color:data-bar-vertical-ascending-24","\u002Fposts","posts",[237,248,266,292,302,316,326,336,346,372],{"title":238,"icon":239,"redirect":240,"path":241,"stem":242,"children":243,"page":247},"Database","material-icon-theme:database","\u002Fposts\u002Fdatabase\u002Freplication-strategy","\u002Fposts\u002Fdatabase","posts\u002Fdatabase",[244],{"title":245,"path":240,"stem":246,"icon":212},"Database Replication strategy in large systems","posts\u002Fdatabase\u002Freplication-strategy",false,{"title":249,"icon":250,"redirect":251,"path":252,"stem":253,"children":254,"page":247},"Docker","vscode-icons:file-type-docker2","\u002Fposts\u002Fdocker\u002Fdocker-commands","\u002Fposts\u002Fdocker","posts\u002Fdocker",[255,258,262],{"title":256,"path":251,"stem":257,"icon":212},"Docker commands essentials","posts\u002Fdocker\u002Fdocker-commands",{"title":259,"path":260,"stem":261,"icon":212},"Some useful Dockerfile templates","\u002Fposts\u002Fdocker\u002Fdockerfile-templates","posts\u002Fdocker\u002Fdockerfile-templates",{"title":263,"path":264,"stem":265,"icon":212},"Setup Docker environment on Windows","\u002Fposts\u002Fdocker\u002Fsetup-docker-on-window","posts\u002Fdocker\u002Fsetup-docker-on-window",{"title":267,"icon":268,"redirect":269,"path":270,"stem":271,"children":272,"page":247},"Git & GitHub","material-icon-theme:git","\u002Fposts\u002Fgit\u002Fbrightly-decorate-graph","\u002Fposts\u002Fgit","posts\u002Fgit",[273,276,280,284,288],{"title":274,"path":269,"stem":275,"icon":212},"Brightly decorate your GitHub Graph","posts\u002Fgit\u002Fbrightly-decorate-graph",{"title":277,"path":278,"stem":279,"icon":212},"Download a specific folder on GitHub repository","\u002Fposts\u002Fgit\u002Fdownload-specific-folder","posts\u002Fgit\u002Fdownload-specific-folder",{"title":281,"path":282,"stem":283,"icon":212},"Syncing Git Tags across to other repositories","\u002Fposts\u002Fgit\u002Fsyncing-tags-across-repositories","posts\u002Fgit\u002Fsyncing-tags-across-repositories",{"title":285,"path":286,"stem":287,"icon":212},"Unlocking GitHub Achievement badges","\u002Fposts\u002Fgit\u002Funlocking-achievement-badges","posts\u002Fgit\u002Funlocking-achievement-badges",{"title":289,"path":290,"stem":291,"icon":212},"Essential Git commands every developer should master","\u002Fposts\u002Fgit\u002Fuseful-commands-like-pro","posts\u002Fgit\u002Fuseful-commands-like-pro",{"title":293,"icon":294,"redirect":295,"path":296,"stem":297,"children":298,"page":247},"Golang","material-icon-theme:go","\u002Fposts\u002Fgolang\u002Foptimizing-performance-with-pgo","\u002Fposts\u002Fgolang","posts\u002Fgolang",[299],{"title":300,"path":295,"stem":301,"icon":212},"Optimizing Performance in Go Applications with PGO","posts\u002Fgolang\u002Foptimizing-performance-with-pgo",{"title":303,"icon":304,"redirect":305,"path":306,"stem":307,"children":308,"page":247},"JavaScript","vscode-icons:file-type-js","\u002Fposts\u002Fjavascript\u002F9-lines-of-tips","\u002Fposts\u002Fjavascript","posts\u002Fjavascript",[309,312],{"title":310,"path":305,"stem":311,"icon":212},"9 lines of JavaScript replace 50 lines of code","posts\u002Fjavascript\u002F9-lines-of-tips",{"title":313,"path":314,"stem":315,"icon":212},"Javascript Promises - Specific functions and use cases","\u002Fposts\u002Fjavascript\u002Fpromises-cheatsheet","posts\u002Fjavascript\u002Fpromises-cheatsheet",{"title":317,"icon":318,"redirect":319,"path":320,"stem":321,"children":322,"page":247},"Node","material-icon-theme:nodejs-alt","\u002Fposts\u002Fnodejs\u002Fevent-loop","\u002Fposts\u002Fnodejs","posts\u002Fnodejs",[323],{"title":324,"path":319,"stem":325,"icon":212},"Secret about Event Loop flow in Nodejs","posts\u002Fnodejs\u002Fevent-loop",{"title":327,"icon":328,"redirect":329,"path":330,"stem":331,"children":332,"page":247},"Nuxt","vscode-icons:file-type-nuxt","\u002Fposts\u002Fnuxt\u002Fenable-pwa-in-nuxt","\u002Fposts\u002Fnuxt","posts\u002Fnuxt",[333],{"title":334,"path":329,"stem":335,"icon":212},"Enable PWA and Service Worker in Nuxt","posts\u002Fnuxt\u002Fenable-pwa-in-nuxt",{"title":337,"icon":338,"redirect":339,"path":340,"stem":341,"children":342,"page":247},"Performance","emojione:rocket","\u002Fposts\u002Fperformance\u002Fbackground-image-injection-problem","\u002Fposts\u002Fperformance","posts\u002Fperformance",[343],{"title":344,"path":339,"stem":345,"icon":212},"Background-Image injection problem in UX","posts\u002Fperformance\u002Fbackground-image-injection-problem",{"title":347,"icon":348,"redirect":349,"path":350,"stem":351,"children":352,"page":247},"Tutorial","fluent-color:book-open-lightbulb-24","\u002Fposts\u002Ftutorial\u002Fclassification-and-functionality-of-the-servers","\u002Fposts\u002Ftutorial","posts\u002Ftutorial",[353,356,360,364,368],{"title":354,"path":349,"stem":355,"icon":212},"Classification and functionality of the servers","posts\u002Ftutorial\u002Fclassification-and-functionality-of-the-servers",{"title":357,"path":358,"stem":359,"icon":212},"What is the difference between localhost and 127.0.0.1?","\u002Fposts\u002Ftutorial\u002Fdifferent-between-localhost-and-127-0-0-1","posts\u002Ftutorial\u002Fdifferent-between-localhost-and-127-0-0-1",{"title":361,"path":362,"stem":363,"icon":212},"8 essential network protocols every programmer should know","\u002Fposts\u002Ftutorial\u002Fessential-network-protocols","posts\u002Ftutorial\u002Fessential-network-protocols",{"title":365,"path":366,"stem":367,"icon":212},"Pre rels in header link tag - SEO technique enhancement","\u002Fposts\u002Ftutorial\u002Fpre-rels-in-header-link-tag","posts\u002Ftutorial\u002Fpre-rels-in-header-link-tag",{"title":369,"path":370,"stem":371,"icon":212},"Better code with SOLID principles","\u002Fposts\u002Ftutorial\u002Fwhat-is-solid","posts\u002Ftutorial\u002Fwhat-is-solid",{"title":373,"icon":374,"redirect":375,"path":376,"stem":377,"children":378,"page":247},"UI\u002FUX","devicon:figma","\u002Fposts\u002Fuiux\u002Fcommon-button-mistake","\u002Fposts\u002Fuiux","posts\u002Fuiux",[379],{"title":380,"path":375,"stem":381,"icon":212},"Common Button Mistake in UI\u002FUX","posts\u002Fuiux\u002Fcommon-button-mistake",{"title":383,"icon":384,"path":385,"stem":386,"children":387,"page":247},"Cheatsheets","fluent-color:paw-16","\u002Fcheatsheets","cheatsheets",[388,393,398,401,406,409,414,418,423,428,433,438,443,448,452,456,461,466,470,475,480,485],{"title":389,"path":390,"stem":391,"icon":392},"Bash","\u002Fcheatsheets\u002Fbash","cheatsheets\u002Fbash","material-icon-theme:powershell",{"title":394,"path":395,"stem":396,"icon":397},"CSS","\u002Fcheatsheets\u002Fcss","cheatsheets\u002Fcss","vscode-icons:file-type-css2",{"title":249,"path":399,"stem":400,"icon":250},"\u002Fcheatsheets\u002Fdocker","cheatsheets\u002Fdocker",{"title":402,"path":403,"stem":404,"icon":405},"Git","\u002Fcheatsheets\u002Fgit","cheatsheets\u002Fgit","devicon:git",{"title":293,"path":407,"stem":408,"icon":294},"\u002Fcheatsheets\u002Fgo","cheatsheets\u002Fgo",{"title":410,"path":411,"stem":412,"icon":413},"HTML","\u002Fcheatsheets\u002Fhtml","cheatsheets\u002Fhtml","material-icon-theme:html",{"title":303,"path":415,"stem":416,"icon":417},"\u002Fcheatsheets\u002Fjavascript","cheatsheets\u002Fjavascript","material-icon-theme:javascript",{"title":419,"path":420,"stem":421,"icon":422},"Latex","\u002Fcheatsheets\u002Flatex","cheatsheets\u002Flatex","material-icon-theme:latexmk",{"title":424,"path":425,"stem":426,"icon":427},"Linux","\u002Fcheatsheets\u002Flinux","cheatsheets\u002Flinux","devicon:linux",{"title":429,"path":430,"stem":431,"icon":432},"Markdown","\u002Fcheatsheets\u002Fmarkdown","cheatsheets\u002Fmarkdown","material-icon-theme:markdown",{"title":434,"path":435,"stem":436,"icon":437},"Mongo","\u002Fcheatsheets\u002Fmongo","cheatsheets\u002Fmongo","devicon:mongodb",{"title":439,"path":440,"stem":441,"icon":442},"Nest","\u002Fcheatsheets\u002Fnest","cheatsheets\u002Fnest","material-icon-theme:nest",{"title":444,"path":445,"stem":446,"icon":447},"Next","\u002Fcheatsheets\u002Fnext","cheatsheets\u002Fnext","logos:nextjs-icon",{"title":317,"path":449,"stem":450,"icon":451},"\u002Fcheatsheets\u002Fnode","cheatsheets\u002Fnode","material-icon-theme:nodejs",{"title":327,"path":453,"stem":454,"icon":455},"\u002Fcheatsheets\u002Fnuxt","cheatsheets\u002Fnuxt","material-icon-theme:nuxt",{"title":457,"path":458,"stem":459,"icon":460},"React","\u002Fcheatsheets\u002Freact","cheatsheets\u002Freact","material-icon-theme:react",{"title":462,"path":463,"stem":464,"icon":465},"Redis","\u002Fcheatsheets\u002Fredis","cheatsheets\u002Fredis","vscode-icons:folder-type-redis-opened",{"title":467,"path":468,"stem":469,"icon":239},"SQL","\u002Fcheatsheets\u002Fsql","cheatsheets\u002Fsql",{"title":471,"path":472,"stem":473,"icon":474},"Typescript","\u002Fcheatsheets\u002Ftypescript","cheatsheets\u002Ftypescript","material-icon-theme:typescript",{"title":476,"path":477,"stem":478,"icon":479},"Vercel","\u002Fcheatsheets\u002Fvercel","cheatsheets\u002Fvercel","vscode-icons:file-type-light-vercel",{"title":481,"path":482,"stem":483,"icon":484},"Vue","\u002Fcheatsheets\u002Fvue","cheatsheets\u002Fvue","material-icon-theme:vue",{"title":486,"path":487,"stem":488,"icon":489},"Windows","\u002Fcheatsheets\u002Fwindow","cheatsheets\u002Fwindow","material-icon-theme:folder-windows",{"title":491,"icon":492,"path":493,"stem":494,"children":495,"page":247},"Prompts","fluent-color:bot-sparkle-24","\u002Fprompts","prompts",[496],{"title":497,"path":498,"stem":499,"children":500,"page":247},"Image Generation","\u002Fprompts\u002Fimage-generation","prompts\u002Fimage-generation",[501],{"title":502,"path":503,"stem":504,"icon":492},"Futuristic Cloud Workspace","\u002Fprompts\u002Fimage-generation\u002Ffuturistic-cloud-workspace","prompts\u002Fimage-generation\u002Ffuturistic-cloud-workspace",{"title":506,"icon":507,"path":508,"stem":509,"children":510,"page":247},"Interviews","lucide:messages-square","\u002Finterviews","interviews",[511,515,520,523,527,532,534,535,537,542,547],{"title":512,"path":513,"stem":514,"icon":507},"Behavioral Engineering","\u002Finterviews\u002Fbehavioral-engineering","interviews\u002Fbehavioral-engineering",{"title":516,"path":517,"stem":518,"icon":519},"DevOps and Cloud","\u002Finterviews\u002Fdevops-cloud","interviews\u002Fdevops-cloud","logos:docker-icon",{"title":410,"path":521,"stem":522,"icon":413},"\u002Finterviews\u002Fhtml","interviews\u002Fhtml",{"title":303,"path":524,"stem":525,"icon":526},"\u002Finterviews\u002Fjavascript","interviews\u002Fjavascript","logos:javascript",{"title":528,"path":529,"stem":530,"icon":531},"Node.js and API Design","\u002Finterviews\u002Fnodejs-api","interviews\u002Fnodejs-api","logos:nodejs-icon",{"title":223,"path":224,"stem":225,"icon":533},"lucide:flask-conical",{"title":5,"path":214,"stem":218,"icon":210},{"title":227,"path":228,"stem":229,"icon":536},"lucide:network",{"title":538,"path":539,"stem":540,"icon":541},"TypeScript","\u002Finterviews\u002Ftypescript","interviews\u002Ftypescript","logos:typescript-icon",{"title":543,"path":544,"stem":545,"icon":546},"Vue and Nuxt","\u002Finterviews\u002Fvue-nuxt","interviews\u002Fvue-nuxt","logos:nuxt-icon",{"title":548,"path":549,"stem":550,"icon":551},"Web Security","\u002Finterviews\u002Fweb-security","interviews\u002Fweb-security","lucide:shield-check"]