You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The cost of merged cell filling is extremely high for LINQ queries. #837
Enabling merged cell filling (FillMergedCells = true) has a significant performance impact on LINQ queries, even when using simple operations like .Skip() or .First().
In our case, after setting:
var a = MiniExcel.Query(@"D:\Test1,000,000x10.xlsx", configuration: new OpenXmlConfiguration() { FillMergedCells = true }).First();
Reproduced on master (c7fb0bd, v2 API, net10.0). I used a 300k rows × 10 columns sheet that has a <dimension> element, as Excel writes it:
FillMergedCells
Query(path).First()
false
~0 ms
true
~700 ms (675 and 742 ms in two runs)
The cause: OpenXmlReader.InternalQueryRangeAsync calls TryGetMergeCellsAsync before it yields the first row. That method (OpenXmlReader.MergeCells.cs, around line 21) loops while (await reader.ReadAsync()) over every node of the sheet to reach <mergeCells>, which the schema places after <sheetData>. In my file that is about 18M nodes, so the whole sheet is tokenized before row 1 comes back, and the cost grows with the file size.
For comparison, in a stand-alone test on the same sheet entry:
a plain XmlReader pass took 550–1200 ms;
just inflating the entry took 55–80 ms.
A raw scan for the mergeCells element that parses only from there could remove most of the cost, but I haven't implemented or tested that inside MiniExcel.
Workaround for now: leave FillMergedCells off when you only need the first rows, or read once and cache the result.
Activity
menes97 commentedon Nov 19, 2026
Reproduced on master (c7fb0bd, v2 API, net10.0). I used a 300k rows × 10 columns sheet that has a
<dimension>element, as Excel writes it:FillMergedCellsQuery(path).First()falsetrueThe cause:
OpenXmlReader.InternalQueryRangeAsynccallsTryGetMergeCellsAsyncbefore it yields the first row. That method (OpenXmlReader.MergeCells.cs, around line 21) loopswhile (await reader.ReadAsync())over every node of the sheet to reach<mergeCells>, which the schema places after<sheetData>. In my file that is about 18M nodes, so the whole sheet is tokenized before row 1 comes back, and the cost grows with the file size.For comparison, in a stand-alone test on the same sheet entry:
XmlReaderpass took 550–1200 ms;A raw scan for the
mergeCellselement that parses only from there could remove most of the cost, but I haven't implemented or tested that inside MiniExcel.Workaround for now: leave
FillMergedCellsoff when you only need the first rows, or read once and cache the result.