Speed up your COUNT(DISTINCT) queries

How to speed up COUNT(DISTINCT)

This post's contentCOUNT(*) vs COUNT(field) vs COUNT(DISTINCT field)COUNT(*)COUNT(field)COUNT(DISTINCT field)How to speed up COUNT(DISTINCT)Speed up COUNT(DISTINCT) using database estimatesApproximate count using the database cardinality estimate tablesApproximate count using the result of EXPLAINSpeed up COUNT(DISTINCT) using aggregationsAggregating via materialized viewsAggregating via dedicated data structures: hyperloglogSpeed up COUNT(DISTINCT) using covering indexesReviewing EverSQL optimiser suggestionsSpeed up COUNT(DISTINCT) by re-evaluating… Continue reading How to speed up COUNT(DISTINCT)

How to print (and optimize) Prisma raw queries

How to print Prisma raw SQL query and optimize it

This post's contentThe starting point - a Prisma appThe Prisma function definitionSet Prisma client SQL query loggingOptimize the Prisma raw queryTranslate a SQL index suggestion to PrismaAdditional ways to optimize your Prisma raw queriesMake Prisma queries faster In modern application development, we often abstract direct access to the database layer from the application layer using… Continue reading How to print Prisma raw SQL query and optimize it

5 Ways to implement NOT EXISTS in PostgreSQL

5 Ways to implement NOT EXISTS in PostgreSQL

This post's contentWhat Does the NOT EXISTS Operator do in PostgreSQL?What does the NOT EXISTS operator return?Create a PostgreSQL databasePopulate the PostgreSQL databaseUsing EXISTSWhen EXISTS is slowWhen EXISTS is fastUsing NOT INWhen NOT IN is slowWhen NOT IN is fastUsing <> ALLWhen <> ALL is slowWhen <> ALL is fastUsing LEFT JOINWhen LEFT JOIN is… Continue reading 5 Ways to implement NOT EXISTS in PostgreSQL

Aiven acquires EverSQL 🎉

By Oded Valin and Tomer Shay We are thrilled to share that we are joining Aiven, the leading open source cloud data platform. This is an exciting milestone in the EverSQL journey. From our early days spent in a coffee shop conceptualizing how we could solve the real-world challenge of database optimization to free up… Continue reading Aiven acquires EverSQL 🎉

PostgreSQL is taking the lead

This post's contentDB ranking in the last 10 yearsPostgreSQL crowned by StackOverflow Survey in 2023Cloud vendors are going in a PostgreSQL-first approachDatabase migrations are tailored to PostgreSQLCustom databases are built on top of PostgreSQLYour thoughts? This is not a "which database is the best in 2023" article. I don't think that's a simple question to… Continue reading PostgreSQL is taking the lead

Resolving ServiceNow Performance Issues

This post's contentThe Problem: Slow Dashboards and Growing FrustrationInvestigating the Root CauseServiceNow Internal Configuration TuningImplementing EverSQL: A Game-ChangerResults and Lessons Learned: A More Robust SystemConclusion: A Journey Worth Taking As the CTO of a major telco company in the US, managing our IT infrastructure is a crucial part of my daily responsibilities. ServiceNow, with its… Continue reading Resolving ServiceNow Performance Issues

Postgresql SQL optimization [2023 edition]

This post's contentHow I fixed my Slow PostgreSQL and made it faster:Identifying slow queriesIndexingJoinsSubqueriesMaterialized ViewspgBadgerEverSQLGranulatePartitioningConfiguration OptimizationShould I upgrade my PostgreSQL version?Does new PostgreSQL versions include new performance capabilities?Summary How I fixed my Slow PostgreSQL and made it faster: In this post I will share our experience in making PostgreSQL faster and will provide actionable tips… Continue reading Postgresql SQL optimization [2023 edition]

My Oracle to PostgreSQL Migration: The 7 Tools That Made It Possible

This post's contentOverview of the Migration ProcessOra2PgAWS Database Migration Service (DMS)pgLoaderForeign Data Wrappers (FDW)pg_dump, pg_restore and additional built-in PG featuresEverSQL, for Post Migration TuningNpgsqlCommon Pitfalls in Migrating from Oracle to PostgreSQL1. Differences in SQL Syntax and Functionality2. Transaction Behavior3. Case Sensitivity4. Sequences and Auto-Incrementing5. Data Types6. NULLs and Empty Strings7. Date and Time TypesConclusion I… Continue reading My Oracle to PostgreSQL Migration: The 7 Tools That Made It Possible