Exploring the Data and Stored Embeddings in PostgreSQL
Introduction: Getting Familiar with Stored Data
Now that you have set up your PostgreSQL database with the pgvector extension and reviewed the structure of the products table, it’s time to take the next step: exploring the actual data stored in the table. In the previous lesson, you learned about the purpose of embeddings and how the table is designed to store them. In this lesson, you will see how to view the data itself, including the embeddings, so you can become comfortable with what is stored and how it appears in the database. This is an important step before you start running more advanced queries or similarity searches, as it helps you understand the foundation you are working with.
Key Columns for Exploration
As a quick reminder, the products table contains several columns, but for the purpose of exploring stored embeddings, you will focus on four key columns: product_id, product_name, description, and embedding. The product_id is a unique identifier for each product, while product_name and description provide basic information about the product. The embedding column is where the vector representation of each product is stored. These columns are the most relevant when you want to inspect the data and see how embeddings are associated with each product.
Example: Selecting Products and Their Embeddings
To view the data in the products table, you can use a simple SQL SELECT statement. Here is an example query that retrieves the first five products, including their embeddings:
When you run this query, you will see the following output:
In this output, each row represents a product, and the embedding column contains a vector — a long list of numbers inside square brackets. The actual embedding will have many more numbers (for example, 384 values if you are using a 384-dimensional embedding), but for display purposes, you may see only a portion of the vector or an abbreviated version.
