Apache Pinot
What is Apache Pinot?
Apache Pinot
What is Apache Pinot?
Apache Pinot is a real-time distributed OLAP (Online Analytical Processing) datastore designed for low-latency, high-throughput analytics. Think of it as a specialized database optimized for quickly querying large datasets, particularly those that are constantly changing. It’s not a general-purpose database like MySQL or PostgreSQL; instead, it’s built for specific use cases where speed and real-time insights are paramount.
Here’s a breakdown of its key characteristics:
- Columnar Storage: Pinot stores data in a columnar format, which is highly efficient for analytical queries that typically involve reading only a subset of columns. This contrasts with row-based storage, where entire rows are read even if only a few columns are needed.
- Indexing: Pinot supports various indexing techniques (e.g., inverted indexes, range indexes) to accelerate query performance. These indexes allow Pinot to quickly locate the relevant data without scanning the entire dataset.
- Real-Time Ingestion: Pinot can ingest data from streaming sources (like Apache Kafka) in real-time, making it suitable for applications that require up-to-the-minute analytics.
- Scalability and Fault Tolerance: Pinot is designed to scale horizontally by adding more nodes to the cluster. It also provides fault tolerance through data replication and other mechanisms.
- SQL-like Query Language: Pinot uses a SQL-like query language (PQL) that is easy to learn and use for data analysis.
- Pluggable Architecture: Pinot has a pluggable architecture that allows users to extend its functionality with custom plugins.

Who Uses Apache Pinot?
User-facing, real-time analytics
Pinot was originally built at LinkedIn to power rich interactive real-time analytics applications, such as Who Viewed Profile, Company Analytics, Talent Insights, and many more. UberEats Restaurant Manager is another example of a user-facing analytics app built with Pinot.
Pinot is used by a wide range of companies and organizations that need to analyze large, fast-moving datasets in real-time. Here are some common use cases and the types of organizations that benefit:
- Real-Time Analytics Dashboards: Companies that need to monitor key performance indicators (KPIs) in real-time, such as website traffic, application performance, or business metrics. Examples include:
- E-commerce: Tracking sales, user behavior, and inventory levels.
- Ad Tech: Analyzing ad impressions, clicks, and conversions.
- Financial Services: Monitoring trading activity, risk, and fraud.
- User Behavior Analysis: Understanding how users interact with applications or websites, including clickstreams, page views, and feature usage.
- Social Media: Analyzing user engagement, content trends, and sentiment.
- Gaming: Tracking player behavior, game performance, and monetization.
- Time-Series Data Analysis: Analyzing data that changes over time, such as sensor data, network traffic, or financial data.
- IoT (Internet of Things): Analyzing data from connected devices.
- Network Monitoring: Tracking network performance and security threats.
- Search and Recommendation: Powering search and recommendation engines that require real-time data updates.
- E-commerce: Providing personalized product recommendations.
- Content Platforms: Recommending relevant articles, videos, or music.
How Can You Use Apache Pinot?
Here’s a high-level overview of how you can use Apache Pinot:
Setup:
- Download and Install: Download the Pinot distribution and set up a cluster of Pinot servers. https://pinot.apache.org/download/
- Configure: Configure the Pinot cluster, including the number of servers, data storage locations, and other settings.
Data Ingestion:
- Define Schemas: Define the schema for your data, specifying the data types and indexing options.
- Ingest Data: Ingest data from your data sources, such as Apache Kafka, batch files, or other systems. Pinot supports both real-time and batch ingestion.
Querying:
- Use PQL: Use the Pinot Query Language (PQL) to query your data. PQL is similar to SQL and allows you to perform aggregations, filtering, and other analytical operations.
- Integrate with Applications: Integrate Pinot with your applications using the Pinot client libraries (available for Java, Python, and other languages).
Monitoring and Management:
- Monitor Performance: Monitor the performance of your Pinot cluster using the Pinot monitoring tools.
- Manage Cluster: Manage your Pinot cluster, including adding or removing servers, and performing other administrative tasks.
Benefits of Using Apache Pinot
- Low Latency: Pinot is designed for extremely fast query performance, enabling real-time analytics.
- High Throughput: Pinot can handle a large volume of queries and data ingestion.
- Scalability: Pinot can scale horizontally to accommodate growing data volumes and query loads.
- Real-Time Analytics: Pinot enables real-time analysis of streaming data, providing up-to-the-minute insights.
- Cost-Effective: Pinot’s columnar storage and indexing techniques can reduce storage costs and improve query performance.
- Flexibility: Pinot’s pluggable architecture allows users to extend its functionality with custom plugins.
- Open Source: Pinot is an open-source project, which means it’s free to use and modify.
- Mature and Active Community: Pinot has a large and active community, which provides support and resources for users.
UPSERT
- What is Upsert in the Context of Apache Pinot?
- In database terms, an “upsert” is a combination of “update” and “insert.” It means:
- If a record with a specific key exists, update it.
- If a record with that key doesn’t exist, insert it as a new record.
In Apache Pinot, upsert functionality is designed to handle real-time data streams where records might be new or updates to existing records. This is particularly important for use cases like:
- Real-time dashboards: Where you need to reflect the latest state of your data.
- User profiles: Where user information is constantly being updated.
- Inventory management: Where stock levels change frequently.
Key Concepts in Pinot Upsert
- Primary Key:
- Upsert relies on a primary key to identify records. This key is a combination of one or more columns that uniquely identify a row.
- You must define the primary key when creating your Pinot table.
- Real-time Data Ingestion:
- Upsert is primarily used with real-time data ingestion from sources like Kafka.
- Pinot consumes data streams and applies upsert logic as it ingests new records.
- Segment Merging:
- Pinot stores data in segments. When new data is ingested, it might create new segments.
- Pinot’s segment merging process ensures that upserted records are correctly reflected in the merged segments.
- Last-Write-Wins (LWW):
- By default, Pinot uses a “last-write-wins” strategy for upserts. This means that if multiple updates for the same key arrive, the latest update (based on a timestamp column) will be applied.
- You can configure the timestamp column used for LWW.
- Partial Updates:
- Pinot supports partial updates. You don’t need to provide all columns in an update; only the columns you want to change.
How to Configure Upsert in Pinot
- Table Schema:
- Define the primary key columns in your table schema.
- Specify the timestamp column used for LWW.
{
"tableName": "myTable",
"tableType": "REALTIME",
"segmentsConfig": {
"timeColumnName": "timestamp",
"replication": "1"
},
"fieldConfigList": [
{
"name": "id",
"dataType": "INT",
"transformFunction": "NONE"
},
{
"name": "name",
"dataType": "STRING",
"transformFunction": "NONE"
},
{
"name": "value",
"dataType": "DOUBLE",
"transformFunction": "NONE"
},
{
"name": "timestamp",
"dataType": "LONG",
"transformFunction": "NONE"
}
],
"primaryKeyColumns": ["id"],
"upsertConfig": {
"mode": "PARTIAL",
"timeColumnName": "timestamp"
}
}
primaryKeyColumns: Specifies the columns that form the primary key.upsertConfig.mode: Set to "PARTIAL" for partial updates.upsertConfig.timeColumnName: Specifies the timestamp column for LWW.
- Data Ingestion:
- When ingesting data, ensure that your records include the primary key columns and the timestamp column.
- Pinot will automatically handle the upsert logic based on the configuration.
Example Scenario
Let’s say you have a table called user_profiles with the following schema:
user_id(INT, primary key)name(STRING)email(STRING)last_login(LONG, timestamp)
- Initial Data:
- You ingest a record:
{user_id: 1, name: "Alice", email: "alice@example.com", last_login: 1678886400}
- Update:
- You ingest an update:
{user_id: 1, email: "alice.new@example.com", last_login: 1678886500}
- Result:
- Pinot will update the existing record for
user_id = 1. The final record will be:{user_id: 1, name: "Alice", email: "alice.new@example.com", last_login: 1678886500}
- New Record:
- You ingest a new record:
{user_id: 2, name: "Bob", email: "bob@example.com", last_login: 1678886600}
- Result:
- Pinot will insert a new record for
user_id = 2.
Benefits of Pinot Upsert
- Real-time Data Accuracy: Ensures that your data reflects the latest updates.
- Simplified Data Management: Handles updates and inserts automatically.
- Efficient Data Processing: Optimized for real-time data streams.
- Reduced Data Duplication: Avoids creating duplicate records.
Considerations
- Primary Key Design: Choose a primary key that uniquely identifies your records.
- Timestamp Column: Ensure that your timestamp column is accurate and consistent.
- Performance: Upsert operations can have performance implications, especially with high data volumes.
- Data Consistency: Understand the LWW behavior and its implications for data consistency.
Apache Pinot’s upsert functionality is a powerful tool for managing real-time data updates. By understanding the key concepts and configuration options, you can leverage upsert to build accurate and up-to-date applications. Remember to carefully design your primary key and timestamp column to ensure data integrity and performance.
Alternatives?
Druid
- Strengths:
- Real-time Ingestion: Excellent for real-time data ingestion and analysis.
- Scalability: Designed for handling large datasets and high query loads.
- Time-Series Data: Well-suited for time-series data analysis.
- Pre-aggregation: Supports pre-aggregation for faster queries.
- Weaknesses:
- Complexity: Can be complex to set up and manage.
- SQL Support: SQL support is not as comprehensive as ClickHouse.
- Cost: Can be more expensive to operate than Pinot.
- When to Choose: If you need a robust solution for real-time time-series data analysis and are comfortable with its complexity.
Elasticsearch:
- Strengths:
- Full-Text Search: Excellent for full-text search and indexing.
- Scalability: Highly scalable and distributed.
- Flexibility: Can handle various data types and formats.
- Weaknesses:
- Analytical Queries: Not as optimized for analytical queries as Pinot, ClickHouse, or Druid.
- Cost: Can be expensive for large-scale analytical workloads.
- When to Choose: If you need a combination of search and analytics, and your analytical queries are not too complex.
BigQuery (Google Cloud Platform):
- Strengths:
- Fully Managed: A fully managed, serverless data warehouse.
- Scalability: Highly scalable and can handle massive datasets.
- SQL Support: Supports standard SQL.
- Weaknesses:
- Real-time Ingestion: Not as optimized for real-time ingestion as Pinot.
- Cost: Can be expensive for large-scale, frequent queries.
- Vendor Lock-in: Tied to the Google Cloud Platform.
- When to Choose: If you need a fully managed data warehouse and don’t require extremely low-latency real-time analytics.
Snowflake:
- Strengths:
- Fully Managed: A fully managed, cloud-based data warehouse.
- Scalability: Highly scalable and can handle large datasets.
- SQL Support: Supports standard SQL.
- Weaknesses:
- Real-time Ingestion: Not as optimized for real-time ingestion as Pinot.
- Cost: Can be expensive for large-scale, frequent queries.
- Vendor Lock-in: Tied to the Snowflake platform.
- When to Choose: If you need a fully managed data warehouse and don’t require extremely low-latency real-time analytics.
In Summary
Apache Pinot is a powerful tool for real-time analytics. If you need to analyze large, fast-moving datasets with low latency and high throughput, Pinot is definitely worth considering. Its columnar storage, indexing capabilities, and real-time ingestion features make it a great choice for a variety of use cases, from real-time dashboards to user behavior analysis and time-series data analysis.
메타데이터
- post_id
- e963da7e9efb
- slug
- apache-pinot-e963da7e9efb
- url
- https://medium.com/@zekeriyabesiroglu/apache-pinot-e963da7e9efb
- canonical_url
- https://medium.com/@zekeriyabesiroglu/apache-pinot-e963da7e9efb
- author_url
- https://medium.com/@zekeriyabesiroglu
- status
- ok
- fetched_at
- 2026-06-28 04:42:08