Skip to content

Jean-Pierre Lambelet

Il n'y a pas de questions bêtes

  • Programming tips
  • General tips
  • About
  • EN
    • FR
    • EN

SQL

PostgreSQL – pgvector – Keep the ivfflat index when you give results a weight

September 28, 2026 by Jean-Pierre Lambelet
farine qui passe à travers un tamis au-dessus d'un bol

In a vector search, you often want some documents to count more than others. An official page should come before an old PDF, an up-to-date page before a stale archive. The easy way seems to be putting that weight straight into the sort. SELECT id, weight * (1 – (embedding <=> :q)) AS score FROM … Read more

Categories SQL Leave a comment

PostgreSQL – How to filter on a column with uppercase letters in its name

April 30, 2026 by Jean-Pierre Lambelet
Baie de serveurs illuminée illustrant une base de données PostgreSQL avec colonnes en majuscule

On PostgreSQL, a column whose name contains an uppercase letter must be wrapped in double quotes to be read or modified. Syntax and best practice to avoid this common pitfall.

Categories SQL

SQL – How to retrieve entries before and after an ID

August 17, 2026October 21, 2013 by Jean-Pierre Lambelet
MacBook avec code sur un bureau

It is possible, for example in the context of a competition, that we are looking to find out what are the 5 best scores preceding the one I just made. To do it in SQL, although a little tricky, it is not too complicated. The 5 before me SELECT * FROM scores WHERE score > … Read more

Categories SQL

SQL – how to change the ORDER BY in a query

August 17, 2026August 13, 2013 by Jean-Pierre Lambelet
MacBook avec code sur un bureau

When it is necessary to have a predefined order in a query, it is possible to change the order of the items by using a CASE in the ORDER BY. In this example id 12 must appear before id 2. SELECT * FROM channel ORDER BY ( CASE WHEN id = 1 THEN 1 WHEN … Read more

Categories SQL

About

Jean-Pierre Lambelet is a Swiss web developer. This blog collects tips and tutorials on generative AI and RAG chatbots, PHP and Symfony, PostgreSQL and Docker.

Recent Posts

  • An LLM crawler that said “ok” for 12 days and extracted nothing
  • Docker – pgvector – Run PostgreSQL with pgvector in Docker Compose
  • PostgreSQL – pgvector – Keep the ivfflat index when you give results a weight
  • Stopping a RAG chatbot from presenting stale information as current
  • Giving a chatbot live weather through LLM tool calling
  • FR
  • EN

Recent Posts

  • An LLM crawler that said “ok” for 12 days and extracted nothing
  • Docker – pgvector – Run PostgreSQL with pgvector in Docker Compose
  • PostgreSQL – pgvector – Keep the ivfflat index when you give results a weight
© 2026 Jean-Pierre Lambelet • RSS feed • Privacy Policy • Ads fund this blog,