All Products
Search
Document Center

PolarDB:Use cases for built-in platform models

Last Updated:Mar 28, 2026

PolarDB for MySQL includes three built-in platform models that let you run LLM-powered inference directly from SQL—no external API calls, application-layer changes, or separate AI service connections required. You deploy a model once, create a SQL function, and then call it inside any SELECT statement.

Available models

FunctionModel nameFile name (SONAME)Return typeUse when
polarchatbuiltin_polarchat#ailib#_builtin_polarchat.soSTRINGYou need interactive Q&A backed by an LLM—ask a question and get a conversational answer.
polarzixunbuiltin_polarzixun#ailib#_builtin_polarzixun.soSTRINGYou need to query a knowledge base with retrieval-augmented generation (RAG)—answers are grounded in retrieved documents rather than model memory alone.
qwenbuiltin_qwen#ailib#_builtin_qwen.soSTRINGYou need general-purpose text generation using the Tongyi Qianwen model directly.

How it works

All three models follow the same three-step pattern:

  1. Deploy the model with DEPLOY MODEL—this registers it with PolarDB for AI.

  2. Register the model as a SQL function with CREATE FUNCTION.

  3. Call the function inside any SELECT statement.

Deploy and call polarzixun

The following steps walk through deploying builtin_polarzixun and calling it with SQL.

Prerequisites

Before you begin, ensure that you have:

Step 1: Deploy the model

Connect to a database and run the following statement to deploy builtin_polarzixun:

/*polar4ai*/ DEPLOY MODEL builtin_polarzixun WITH (mode = 'in_db');

To verify that deployment succeeded, check the model status:

/*polar4ai*/ SHOW MODEL builtin_polarzixun;

The model is ready when its status shows serving.

Step 2: Create the function

CREATE FUNCTION polarzixun RETURNS STRING SONAME "#ailib#_builtin_polarzixun.so";

Step 3: Call the function

Pass any question as a string argument:

SELECT polarzixun("Can ECS instances and PolarDB clusters that are deployed in different regions or across accounts communicate with each other over an internal network?") AS answer;
SELECT polarzixun("How does PolarDB implement load balancing across nodes?") AS answer;
SELECT polarzixun("How do I purchase a PolarDB cluster?") AS answer;
Note

Query results are displayed in Chinese only.

Related topics