GORM issue with different processing time

See code:

    log.Printf("Test 1")
    var resultCount int64
    e.GormDB.Raw("select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = 'AMCOVSB24ER5'").Scan(&resultCount)
    log.Printf("Test 2 - count: %d", resultCount)
    e.GormDB.Raw("select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = ?", filter.InstrumentIdentifier[0]).Scan(&resultCount)
    log.Printf("Test 3 - count: %d", resultCount)
    e.GormDB.Raw("select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = '?'", filter.InstrumentIdentifier[0]).Scan(&resultCount)
    log.Printf("Test 4 - count: %d", resultCount)

Description

Test 2) When I call statement without passing parameter I have very fast response (3 ms) Test 3) When I pass parameter by sign ?, it will response within 14 seconds. Test 4) When I pass parameter into '' it will lead to wrong syntax, but no error is reported and count response with 0.

2023/08/01 16:37:29 Test 1

2023/08/01 16:37:29 C:/Sandbox/rdh_esma/api-go/repository/sqlDbRepository.go:149 SLOW SQL >= 1ms
[2.565ms] [rows:1] select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = 'AMCOVSB24ER5'
2023/08/01 16:37:29 Test 2 - count: 1

2023/08/01 16:37:44 C:/Sandbox/rdh_esma/api-go/repository/sqlDbRepository.go:151 SLOW SQL >= 1ms
[14395.022ms] [rows:1] select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = 'AMCOVSB24ER5'
2023/08/01 16:37:44 Test 3 - count: 1

2023/08/01 16:37:44 C:/Sandbox/rdh_esma/api-go/repository/sqlDbRepository.go:153 SLOW SQL >= 1ms
[2.562ms] [rows:1] select count(*) FROM rdh.esma_fitrs_neq WHERE esma_FITRS_NEQ.Instrument_Identifier = ''AMCOVSB24ER5''
2023/08/01 16:37:44 Test 4 - count: 0

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: Petr-Markvart

It looks like issue with usage of DB table indexes. It was query from table with millions of rows. We are using Azure SQL DB. Moved to different solution without Gorm library and it works fine for us. Any way I can see issue with wrong handling query where is bad syntax (case 4).

We are using: github.com/microsoft/go-mssqldb v1.3.0 gorm.io/driver/sqlserver v1.5.1 gorm.io/gorm v1.25.2

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking