Highload-Block Optimization: Approaches and Tools
Imagine a highload block with an order history of 5 million rows—a filtered query by date takes 40 seconds. After optimization—8 milliseconds. This is achievable with proper indexing, caching, and partitioning. Highload blocks (the highloadblock module) are a Bitrix mechanism for storing arbitrary data in separate tables. Common use cases: event logs, product catalogs with non-standard structure, user profiles, cumulative data (order history, analytics, queues). While rows are under 50–100 thousand, everything works fine. At 1–10 million rows, problems start: the Bitrix ORM generates suboptimal queries, indexes don't cover real selections, JOINs slow down. We have encountered projects where query time was 40 seconds—after optimization it dropped to 8 milliseconds. Savings per query—up to 99.9%.
Why do highload blocks slow down on large data?
Main anti-patterns when working with Highload:
- Missing required indexes. A highload block creates a table with primary key
ID and auto-increment. Custom fields like UF_* are not automatically indexed. A getList(['filter' => ['UF_PRODUCT_ID' => 123]]) on a million rows is a table scan.
- SELECT * like queries. By default, the Bitrix ORM selects all fields. If a record has 30 UF fields, including TEXT and FILE, this is an expensive query even with a small result set.
- Unlimited queries without pagination.
DataManager::getList() without limit returns all records into PHP memory.
- Linked tables via Reference. If a Highload is linked to another Highload or infoblock via Reference fields—the ORM builds a JOIN that kills performance without proper indexes.
- Frequent UPDATE on fields without an index. Typical for status fields, counters.
How to diagnose bottlenecks?
Enable MySQL slow query log:
[mysqld]
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 1
log_queries_not_using_indexes = 1
How to properly index highload tables?
Add indexes via direct SQL—in an agent during installation or a migration script:
$connection = \Bitrix\Main\Application::getConnection();
$tableName = 'b_hl_product_catalog'; // Example
$connection->queryExecute(
"CREATE INDEX IF NOT EXISTS idx_product_id ON {$tableName} (UF_PRODUCT_ID)"
);
$connection->queryExecute(
"CREATE INDEX IF NOT EXISTS idx_status_date ON {$tableName} (UF_STATUS, UF_DATE_CREATE)"
);
What if the ORM still slows down even with indexes?
Explicit SELECT of required fields. Never request select: ['*'] or an empty select array:
$result = ProductCatalogTable::getList([
'select' => ['ID', 'UF_NAME', 'UF_PRICE', 'UF_ACTIVE'],
'filter' => ['UF_CATEGORY_ID' => $categoryId, 'UF_ACTIVE' => 1],
'order' => ['UF_SORT' => 'ASC'],
'limit' => 50,
'offset' => ($page - 1) * 50,
]);
Direct SQL for aggregation. For COUNT, SUM, GROUP BY on large tables—direct SQL is 5–7 times faster than ORM. Use Bitrix\Main\Application::getConnection()->query().
Partitioning for chronological data. If a Highload stores logs or events with dates—partitioning by date range drastically speeds up period queries:
ALTER TABLE b_hl_event_log
PARTITION BY RANGE (YEAR(UF_DATE_CREATE) * 100 + MONTH(UF_DATE_CREATE)) (
PARTITION p_jan VALUES LESS THAN (202402),
PARTITION p_feb VALUES LESS THAN (202403),
PARTITION p_future VALUES LESS THAN MAXVALUE
);
Caching results. Highload data caches well via Bitrix\Main\Data\Cache with tagging. Example implementation:
class CachedProductCatalog
{
private const CACHE_TAG = 'hl_product_catalog';
private const CACHE_TTL = 3600;
public function getByCategory(int $categoryId): array
{
$cache = \Bitrix\Main\Data\Cache::createInstance();
$cacheKey = 'hl_catalog_cat_' . $categoryId;
if ($cache->initCache(self::CACHE_TTL, $cacheKey, '/hl/catalog/')) {
return $cache->getVars();
}
$cache->startDataCache();
// Fetch from DB
$result = $this->fetchFromDb($categoryId);
// Tagged cache
$tagCache = new \Bitrix\Main\Data\TaggedCache();
$tagCache->startTagCache('/hl/catalog/');
$tagCache->registerTag(self::CACHE_TAG . '_' . $categoryId);
$tagCache->endTagCache();
$cache->endDataCache($result);
return $result;
}
}
Benchmarks: what each optimization gives
| Optimization |
1M row table |
10M row table |
| Adding index on filtered field |
4000 ms → 5 ms |
40000 ms → 8 ms |
| SELECT only needed fields |
800 ms → 120 ms |
— |
| Cache hit |
120 ms → 0.5 ms |
— |
| Direct SQL instead of ORM (aggregation) |
350 ms → 45 ms |
3000 ms → 80 ms |
| Partitioning by date |
— |
3000 ms → 60 ms |
Step-by-step optimization plan
- Audit Highload blocks. Collect structure, data volumes, typical queries. Enable slow query log.
- Analyze bottlenecks. Identify top-5 slowest queries by time.
- Add indexes. Create single and composite indexes for actual filters.
- Refactor code. Replace
select: ['*'] with explicit list, implement limits and pagination.
- Implement caching. Use tagged cache for frequently requested data.
- Partition tables. For chronological tables—split by date.
- Load testing. A/B comparison of performance before and after.
What's included in the work
- Audit of Highload blocks: structure, data volume, typical queries and slow query log.
- Bottleneck analysis: identification of top-5 slowest queries.
- Index addition: single and composite indexes for real filter patterns.
- Code refactoring: explicit select, limits, pagination, replacement of ORM with direct SQL where it gives substantial benefit.
- Implementation of tagged cache for heavy selections.
- Partitioning of chronological tables (if needed).
- Load testing with A/B comparison before/after.
- Documentation and training for your developer.
Timeline and pricing
Work timeline: audit + indexes + cache — 2–3 weeks. Full optimization with partitioning and refactoring — 4–8 weeks. Cost is calculated individually based on data volume and complexity. Our team with many years of Bitrix experience and over 50 completed optimization projects guarantees a transparent approach and measurable results. Contact us for a preliminary estimate—we will propose a work plan with checkpoints. Order a performance audit and get an engineer consultation.
Learn more about Highload blocks in the official documentation.
80% of Bitrix sites slow down due to one table
b_iblock_element_property is an EAV structure where each row stores one value of one property of one element. A catalog of 50,000 products with 30 properties yields 1.5 million rows. The smart filter performs a JOIN of this table with b_iblock_element on five properties, and MySQL performs a full table scan for 3–5 seconds. Our experience shows that without intervention in this table, site acceleration is impossible. We take on projects where load time has dropped to 8–10 seconds and bring TTFB back to <200 ms within 1–2 weeks. Site speed optimization begins with an audit of slow queries and ends with a comprehensive turnkey infrastructure overhaul.
Contact us for an audit — we will identify bottlenecks within 2 hours and propose a concrete plan.
How to achieve TTFB below 200 ms?
Server optimization is the first step. Nginx configuration goes beyond simple gzip. Specifically:
-
gzip_comp_level 4-5 — higher is pointless, CPU consumes more than it saves bandwidth.
-
brotli on with brotli_static on for precompressed files.
- HTTP/2 with
http2_max_concurrent_streams 128.
-
fastcgi_cache for PHP responses — caching at Nginx level, bypassing PHP-FPM entirely.
-
worker_processes auto, worker_connections according to the number of simultaneous connections.
PHP-FPM tuning: choose between pm = dynamic and pm = static. Static mode works best for dedicated servers with predictable load because it avoids forking overhead. Dynamic saves RAM under low traffic. Calculate pm.max_children as (available RAM - RAM for MySQL/Redis) / average process consumption. For OPcache set memory_consumption=256, max_accelerated_files=20000, and validate_timestamps=0 in production (restart PHP-FPM on deploy).
MySQL/MariaDB: the main bottleneck is almost always the database. Enable slow_query_log with a threshold of 0.5 sec and analyze every query via EXPLAIN. Set innodb_buffer_pool_size to 70–80% of available RAM on a dedicated server. Create composite indexes for faceted search: (IBLOCK_ID, IBLOCK_PROPERTY_ID, VALUE) on b_iblock_element_property. Run OPTIMIZE TABLE b_iblock_element_property after mass operations.
How to configure three-level caching?
Managed component cache. Set TTL individually for each component. Catalog — 3600 sec, news feed — 300 sec, banners — 86400. The same TTL everywhere guarantees either outdated data or useless cache.
Composite cache. The bitrix:composite technology lets Nginx serve ready HTML from a file; PHP is not executed. Dynamic zones (cart, authorization) are loaded via AJAX request through CBitrixComponent::setFrameMode(true). TTFB drops below 50 ms. However, not all components are compatible; $APPLICATION->ShowPanel() and direct output via echo break the composite. We check every page through the panel 'Performance → Composite Site'. According to Bitrix official documentation on composite cache, this is the most effective caching method for high‑load projects.
Comparison: composite cache is 10–20 times faster than managed cache in time to first byte.
Memcached / Redis. Transfer cache from the file system: sessions go to Redis (session.save_handler = redis) — 10–50 times faster than files, plus cluster support. Component cache goes to Memcached via .settings.php: 'cache' => ['type' => 'memcache']. Also enable ORM query cache so identical GetList() calls don't hit MySQL on every request.
What is the fastest way to optimize Bitrix database?
Default MySQL settings are insufficient. Indexes — composite for faceted search, covering for frequent queries. MySQL responds from the index without accessing the data. Partial indexes (MariaDB) for filtering by ACTIVE = 'Y'. Audit unused indexes — each slows down INSERT/UPDATE.
Partitioning. For tables with millions of rows: b_stat_session, b_search_content_stem, and highload-blocks with history. Partition by date — a query for 'orders in a month' does not scan three years of data. Partitioning also solves the problem of concurrent queries during exchange with 1С via CommerceML.
Real case: a catalog of 200,000 products, 50 properties. Filtering by 10 properties took 12 seconds. After creating composite indexes on (IBLOCK_ID, IBLOCK_PROPERTY_ID, VALUE) and partitioning b_iblock_element_property by IBLOCK_ID, execution time dropped to 0.3 seconds. MySQL load decreased by 40 times.
Cleanup. Over a year or two, any database accumulates: outdated search index, expired records in b_cache_tag, history in b_iblock_element_prop_s*, logs in b_event_log taking gigabytes. We set up regular cleanup via agents.
Frontend and CDN
Images account for 60–80% of page weight. Convert to WebP via CFile::ResizeImageGet() with BX_RESIZE_IMAGE_PROPORTIONAL + conversion. Use srcset + sizes — never load a 3000px image into a 400px block. Add loading="lazy" for everything below the fold. AVIF offers another 20–30% savings vs WebP.
CSS/JS optimization: use the built-in Bitrix module to merge and minify via 'Settings → CSS/JS Optimization'. Apply PurgeCSS / UnCSS — in a typical Bitrix project, 60–70% of CSS is unused. Use defer / async for non‑critical JS and inline critical CSS in <head> for instant FCP.
Fonts: add <link rel="preload" as="font" crossorigin> for the main font. Set font-display: swap — text visible immediately. Subset via pyftsubset — keep only Cyrillic + Latin, file size reduces by 3–5 times.
CDN: Cloudflare, BunnyCDN, AWS CloudFront, or Russian providers (Selectel CDN, VK Cloud CDN). Serve static assets (CSS, JS, images, fonts) via CDN with Cache-Control: public, max-age=31536000, immutable for files with a hash. Use on‑the‑fly image optimization (imgproxy, Cloudflare Polish) without load on origin.
Why is load testing necessary?
Not synthetic benchmarks, but real scenarios: k6 / wrk to simulate routes — catalog → filtering → product card → cart → checkout. Measure RPS, response time (p50, p95, p99), error rate. Use Xdebug (callgrind) or Blackfire for PHP profiling to find bottlenecks. The test result gives an objective picture of where it actually slows down, not where it 'seems'. After optimization, run again to record improvements.
Results
| Metric |
Before |
After |
| TTFB |
800–2000 ms |
50–200 ms |
| Full load |
4–8 sec |
1.5–2.5 sec |
| PageSpeed (mobile) |
30–50 |
80–95 |
| Concurrent users |
50–100 |
500–2000+ |
What is included in the work?
-
Current performance audit — analysis of slow queries, PHP profiling, check of caching, CDN, server settings.
-
Server configuration — Nginx, PHP-FPM, MySQL, Redis/Memcached, OPcache.
-
Caching optimization — managed cache, composite site, TTL configuration, tagged caching.
-
Database work — index creation, partitioning, cleanup, EAV table reorganization.
-
Frontend — images (WebP/AVIF), CSS/JS (minification, deferred), fonts (preload, subsetting).
-
CDN — connection, caching rule setup.
-
Load testing — real user scenarios, metric report.
-
Documentation — description of all changes, recommendations for further maintenance.
-
Guarantee — support for 1 month after delivery, ensuring all optimizations are stable.
Monitoring
Without monitoring, everything degrades in six months. A new module, uncleared logs, a template change — and speed returns to original. Use web-vitals API for Real User Monitoring from actual visitors. Set up synthetic monitoring with Pingdom or UptimeRobot for regular checks from different locations. Configure alerts — TTFB > 500 ms or LCP > 3 sec triggers notification.
Timelines and cost
| Type of work |
Timeline |
| Basic optimization (cache, images, minification) |
2–3 days |
| Database optimization (indexes, slow queries, configuration) |
3–5 days |
| Server infrastructure (Nginx, PHP-FPM, Redis) |
2–3 days |
| Comprehensive (server + database + frontend + CDN) |
1–3 weeks |
| Load testing and profiling |
2–3 days |
| Cluster architecture (balancing, replication) |
1–2 weeks |
Cost is calculated individually after the audit. Get a consultation for your project — we will evaluate the current state and propose an acceleration plan with specific timelines and budget. We are a team with 12+ years of experience in Bitrix, having completed over 300 site speed optimization projects. Contact us to start the performance audit today.