Moving from MySQL to PostgreSQL: Building Flexible Search for the Next Phase of AI
I’ve spent a large part of my career working with PHP and MySQL, building applications, maintaining databases, developing APIs, and managing the processes that keep data platforms running.
That experience has taught me to pay attention to the connection between database design and the experience a customer has on the screen.
At AccuPoint Solutions, we’re transitioning from MySQL to PostgreSQL as we build the next phase of our intelligence platform. A major part of that work is supporting more flexible customer searches, more complex queries, and faster loading times.
The migration is also giving me an opportunity to think more carefully about the database foundation we need for AI-assisted search.
These are some of the capabilities and design questions that stand out to me as we move forward.
A flexible search tool creates many different workloads
A customer-facing search platform has to support a wide range of questions.
One customer might begin with geography and professional credentials. Another might start with firm characteristics. Someone else might combine those conditions, exclude certain records, add a date range, and choose a different sort order.
An illustrative search might be:
Find professionals licensed in selected states, with a business email available, whose firms match a particular set of characteristics.
That request can involve multiple tables, optional filters, inclusion and exclusion rules, sorting, and pagination.
A small change in the customer’s criteria can produce a very different query.
This is where the engineering challenge becomes interesting: how do we keep the experience responsive across the combinations customers actually use?
I want to evaluate the searches that return a few records, the searches that match a large audience, and the more complicated combinations that are easy to overlook during development.
The PostgreSQL capabilities that interest me
What attracts me to PostgreSQL is the range of tools available for matching the database design to different kinds of searches.
Here are several areas I’m paying attention to:
Search requirement
PostgreSQL capability worth evaluating
Customers combine several optional filters
Bitmap index scans that can combine index results with AND and OR
Searches repeatedly target a particular subset of records
Partial indexes defined by a condition
Customers search text in different ways
Full-text search, GIN indexes, and the pg_trgm extension
Some attributes are less uniform or change over time
JSONB and its indexing options
Multiple filters describe related attributes
Extended statistics to help the planner understand certain column relationships
MySQL has useful capabilities in these areas too. Its Index Merge optimization can combine index scans, and its functional indexes can index expression results.
For me, the useful comparison is how each database handles our particular data, queries, and application requirements.
Partial indexes offer a more targeted approach
A PostgreSQL partial index includes only records that satisfy a defined condition.
For example, here is an illustrative index for searches that repeatedly target active professionals:
CREATE INDEX professionals_active_state_name_idx
ON professionals (state, last_name, id)
WHERE is_active = true;
A compatible search could look like this:
SELECT id, first_name, last_name
FROM professionals
WHERE is_active = true
AND state = 'NJ'
ORDER BY last_name, id
LIMIT 50;
This creates an index focused on the active subset. Its usefulness depends on that subset’s size, the query pattern, and the planner’s choices.
The planner also needs to establish that the query satisfies the index condition. Parameterized predicates can complicate that recognition.
For a configurable search builder, that makes the relationship between generated SQL and index design especially important.
Reference: PostgreSQL partial indexes.
Different text searches need different approaches
A platform may need several kinds of text matching:
- An exact identifier lookup.
- A search for words in a description.
- A partial firm name.
- A similarity search that can accommodate some spelling differences.
PostgreSQL provides full-text search, with GIN as its preferred index type for that workload. The pg_trgm extension provides another set of tools for text similarity and indexed pattern searches, including LIKE and ILIKE.
Those tools address different matching requirements. A name search and a document search deserve their own relevance and performance checks.
Trigram indexing also has limits: patterns without extractable trigrams can require a full-index scan. The actual search terms matter.
MySQL also supports full-text search. The opportunity I see in PostgreSQL is having additional approaches to evaluate within the relational platform.
References: PostgreSQL full-text indexes, pg_trgm, and MySQL full-text search.
Flexible attributes still need deliberate data modeling
JSONB is another PostgreSQL feature that interests me for evolving metadata or attributes that do not fit one uniform structure.
PostgreSQL supports GIN indexing for several JSONB containment, existence, and path operations. MySQL also has a native JSON type and indexing approaches for extracted values and arrays.
My preference is to keep core identifiers, relationships, and frequently searched fields clearly modeled, then use flexible structures where they solve a specific problem.
The question is where each attribute belongs and how customers need to query it.
References: PostgreSQL JSONB indexing and MySQL JSON.
Query plans matter as much as the feature list
Flexible search makes execution plans especially useful.
In PostgreSQL, EXPLAIN (ANALYZE, BUFFERS) helps examine actual execution behavior, including row estimates, rows processed, and buffer activity. ANALYZE executes the query, so I would use it deliberately with representative searches.
MySQL also provides EXPLAIN ANALYZE. The habit of inspecting execution plans carries across the migration.
Some questions I want those plans to answer are:
- How much data is examined before the first results are returned?\
- Are row estimates reasonably close to the actual result?
- Which joins, filters, and sorts account for the work?
- Does a small change in the search criteria produce a significantly different plan?
There are useful details to watch. PostgreSQL’s bitmap index combination loses the indexes’ original ordering, so a query may still need an additional sort.
Related filters deserve attention too. Geography fields, for example, can be correlated. PostgreSQL’s extended statistics can help with certain relationships between columns, although they need to be chosen and maintained for the relevant workload.
References: PostgreSQL EXPLAIN, combining indexes, planner statistics, and MySQL EXPLAIN.
Faster loading needs to be measured across the application
Customers experience the time between submitting a search and being able to use the results.
That includes database execution, application processing, response size, network delivery, and browser rendering.
For this migration, I want the evaluation to cover:
- Common searches and difficult combinations.
- Broad results and highly selective results.
- First-page results, pagination, and full exports.
- Exact result counts and any supporting queries.
- Multiple customers searching at the same time.
- Search performance while data updates are running.
A quick first-page query can still leave the customer waiting if the endpoint also performs an expensive count or loads unnecessary data.
Pagination deserves its own design decisions. Cursor-based pagination is worth evaluating for next-page navigation with a stable sort order. Interfaces that require arbitrary page jumps have different requirements.
I would also compare median and 95th-percentile response times under representative load. The slower end of the experience matters when customers can build many different searches.
The goal is consistent, useful performance across the workload.
The AI direction makes a reliable search foundation more important
As we build the next phase of the platform, I’m thinking about how customers can express what they want in more natural language.
That increases the importance of a well-defined search model.
A design principle I want to carry forward is:
- Interpret the customer’s request.
- Translate it into supported fields, operators, and values.
- Validate the search against the customer’s permissions.
- Build a parameterized query through the application’s search layer.
- Return results with criteria the customer can understand and refine.
This gives AI-assisted search a clear connection to the existing search experience.
Semantic similarity is another possibility to evaluate. The optional pgvector extension adds vector similarity search to PostgreSQL, including exact search and approximate indexes such as HNSW and IVFFlat.
Approximate search trades some recall for speed. Combining it with restrictive filters needs testing because filtering can reduce the number of qualifying results returned.
For a business data platform, similarity still needs to work alongside exact criteria and access controls.
Natural-language filter building and vector similarity solve different problems. I want to choose each based on the customer’s task.
What I want to learn from the migration
The move to PostgreSQL is an opportunity to review our query construction, indexing strategy, data model, and application behavior together.
Result correctness is part of that work. Search behavior, sorting, case handling, dates, and null values all need careful validation across the transition.
I also want to understand the operational tradeoffs: index storage, update costs, statistics maintenance, and how the platform behaves as the data changes.
MySQL has been a substantial part of my engineering background. Working with PostgreSQL is expanding the set of approaches I can consider as our search requirements evolve.
The outcome I’m working toward is a platform where customers can ask more varied questions, receive dependable results, and benefit from AI features built on a reliable data foundation.
If you’ve migrated a platform with flexible customer searches, which changes made the biggest difference: the data model, indexes, query construction, or pagination?