Close Menu
MyKnowTech
    MyKnowTech
    • Technical Blogs
    • Career
    • Partner Spotlight
    • Videos
    • Pega News
    • Services
    LinkedIn YouTube Facebook
    MyKnowTech
    Videos

    How Pega Abstracts SQL Queries

    Editorial TeamBy Editorial TeamMay 25, 2026Updated:May 26, 2026No Comments3 Mins Read
    Share LinkedIn Telegram Email WhatsApp Copy Link

    Pega’s low-code approach extends all the way down to database queries. You configure rules. Pega generates and executes the SQL. Understanding the abstraction layer makes you a better developer and a much faster debugger.

    The Rules That Abstract SQL

    There are several ways Pega executes database operations, each suited to different scenarios.

    Activity OBJ methods are the most granular. OBJ browse executes a select query with filter conditions. OBJ open retrieves a specific instance by key. OBJ save and OBJ delete handle inserts, updates and deletes. You configure the method – class, filter conditions, sort order – and Pega generates the SQL.

    Report definitions are the recommended way to query data for reporting and display. You define the table (via class), the columns to return, the where conditions and sort order. Pega converts this into a SQL select query. Report definitions can also join across multiple tables.

    Data pages were originally read-only, executing select queries via lookup or report definition sources. Recent versions added savable data pages, which can handle insert and update operations as well. Data pages are also the right abstraction layer to sit between your rules and any database query – they decouple the source from the consumer.

    Connect SQL is for cases where you need to write your own query directly – typically for external database tables where no class mapping exists, or for complex queries that cannot be expressed through OBJ methods alone.

    What Actually Gets Executed

    The best way to understand the abstraction is to watch the SQL in the tracer.

    Enable DB queries in the tracer settings, then run any activity or data page. The blue lines in the tracer are database operations. Click on any SQL entry to see the exact query Pega generated and executed against the table.

    A few things worth knowing from watching these queries.

    OBJ browse with an equals condition generates a standard where clause with an equals operator. With starts with, Pega generates a left-anchored LIKE query – the wildcard is placed at the end. With contains, it generates a full-text LIKE with wildcards on both sides. Contains is expensive – avoid it on large tables in production.

    OBJ open followed by OBJ save generates a select first, then a merge operation. The merge handles both insert (new instance) and update (existing instance) in one operation. Do not be confused by seeing an insert in the SQL when you expected an update – the merge takes care of the logic correctly.

    A Practical Note on Contains

    Every time you use a contains condition in a report definition or OBJ browse, Pega wraps the search value in wildcards on both sides. This prevents the database from using an index on that column. On a large table with millions of rows, this will cause full table scans and severely impact performance.

    Use starts with or equals where possible. If contains is genuinely required, make sure you have thought through the performance implications and discussed them with your infrastructure team.

    Watch the Full Walkthrough

    In the video below I walk through the three main abstraction rules – OBJ methods in an activity, a report definition and a data page – running each one in the tracer and reading the generated SQL to show exactly how Pega converts low-code configuration into database operations.

    Understanding how your configuration translates to SQL is one of those skills that pays off continuously. When a report is slow or a query is timing out, knowing what Pega is actually running against the database tells you exactly where to start.

    Advanced
    Editorial Team

    An insightful team dedicated to empowering the Pega ecosystem with in-depth knowledge, guided by Premkumar Ganesan's vision.

    Related Posts

    Videos

    Application URL Alias in Pega

    May 25, 2026
    Videos

    Understanding Components in Pega

    May 25, 2026
    Videos

    Understanding CORS Policy in Pega

    May 25, 2026
    Videos

    Content Security Policy in Pega

    May 25, 2026
    Videos

    Five Best Practices for Creating Connectors in Pega

    May 25, 2026
    Videos

    How to Plan a Pega Upgrade – A Practical Guide

    May 25, 2026
    Videos

    How to Analyse a Heap Dump in Pega

    May 25, 2026
    Videos

    How to Store Case Attachments in External File Storage in Pega

    May 25, 2026
    Videos

    Data Encryption in Pega Using HashiCorp Vault

    May 25, 2026
    Videos

    Understanding Stack Memory in Pega

    May 25, 2026
    Search through the blog
    Tags
    activity Advanced authentication background-processing Beginner case-management Constellation data-model declarative-processing email-processing file-processing Integration pega-core-concepts pega-integration process reporting security system-administration user-interface validation
    Pega Courses

    Pega courses can be accessed at https://myknowacademy.com

    About

    MyKnowTech is a boutique Pega enablement and consulting firm – helping organizations build internal Pega capability through structured training programs, Centre of Excellence setup and hands-on architecture guidance.

    Company
    • About
    • Leadership
    • Career
    • Contact
    Resources
    • Technical Blogs
    • Career
    • Partner Spotlight
    • Videos
    • Pega News
    • Services

    ©  MyKnowTech B.V. All Rights Reserved.

    • Sitemap
    • Terms & Conditions
    • Privacy Policy