Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatabaseMetaData getIndexInfo does not include COLUMNSTORE Indexes #2546

Open
goranschwarz opened this issue Nov 22, 2024 · 1 comment · May be fixed by #2566
Open

DatabaseMetaData getIndexInfo does not include COLUMNSTORE Indexes #2546

goranschwarz opened this issue Nov 22, 2024 · 1 comment · May be fixed by #2566
Assignees
Labels
Under Investigation Used for issues under investigation

Comments

@goranschwarz
Copy link
Contributor

Driver version

12.8.1.0

SQL Server version

Microsoft SQL Server 2022 (RTM-GDR) (KB5046861) - 16.0.1135.2 (X64)
Oct 18 2024 15:31:58
Copyright (C) 2022 Microsoft Corporation
Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 22631: ) (Hypervisor)

Client Operating System

Windows (but really any)

JAVA/JVM version

java version "21.0.1" 2023-10-17 LTS

Table schema

WideWorldImporters.Sales.InvoiceLines

Problem description

DatabaseMetaData getIndexInfo does not include COLUMNSTORE Indexes

  • See Screenshot from one of my tools: Image
  • And a Screenshot from SSMS: Image

Expected behavior

That all indexes that re on the table are included in the resultset

Actual behavior

Output of what you actually see.

Error message/stack trace

None

Any other details that can be helpful

Nope

JDBC trace logs

None

@machavan
Copy link
Contributor

machavan commented Nov 25, 2024

The driver calls sp_statistics procedure to get the index info and this procedure's result does not include the COLUMNSTORE indexes

e.g. 
exec sp_statistics 'tcol', 'dbo', 'tpch', '%', 'N', 'E'

We will check why it does not return this info and get back on this.

Meanwhile, as a workaround, a query similar to following on sys.indexes returning this info can be used:



SELECT 
    db_name() AS CatalogName,
    sch.name AS SchemaName,
    t.name AS TableName,
    i.name AS IndexName,
    i.type_desc AS IndexType,
    i.is_unique AS IsUnique,
    c.name AS ColumnName,
    ic.key_ordinal AS ColumnOrder
FROM 
    sys.indexes i
INNER JOIN 
    sys.index_columns ic ON i.object_id = ic.object_id AND i.index_id = ic.index_id
INNER JOIN 
    sys.columns c ON ic.object_id = c.object_id AND ic.column_id = c.column_id
INNER JOIN 
    sys.tables t ON i.object_id = t.object_id
INNER JOIN 
    sys.schemas sch ON t.schema_id = sch.schema_id
WHERE 
	t.name = 'tcol'
	AND sch.name = 'dbo'
ORDER BY 
    t.name, i.name, ic.key_ordinal;

@machavan machavan self-assigned this Nov 25, 2024
@machavan machavan moved this from To be triaged to Under Investigation in MSSQL JDBC Nov 25, 2024
@machavan machavan added the Backlog The topic in question has been recognized and added to development backlog label Nov 25, 2024
@Jeffery-Wasty Jeffery-Wasty moved this from Under Investigation to Backlog in MSSQL JDBC Nov 28, 2024
@Jeffery-Wasty Jeffery-Wasty added Under Investigation Used for issues under investigation and removed Backlog The topic in question has been recognized and added to development backlog labels Nov 29, 2024
@Jeffery-Wasty Jeffery-Wasty moved this from Backlog to Under Investigation in MSSQL JDBC Nov 29, 2024
Ananya2 added a commit that referenced this issue Dec 13, 2024
… query

Replaced the use of the sp_statistics stored procedure with a custom query to retrieve index information as the sp_statistics procedure did not return Columnstore indexes, so a query using sys.indexes was implemented as a workaround.
This new query ensures that all index types (Clustered, NonClustered, Columnstore) are included in the result set.
Github Issue: #2546
@Ananya2 Ananya2 added Under Review Used for pull requests under review and removed Under Review Used for pull requests under review labels Dec 18, 2024
@Ananya2 Ananya2 moved this from Under Investigation to Under Peer Review in MSSQL JDBC Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Under Investigation Used for issues under investigation
Projects
Status: Under Peer Review
Development

Successfully merging a pull request may close this issue.

4 participants