coldbox-modules / qb

Fluent Query Builder for CFML
https://qb.ortusbooks.com/
MIT License
40 stars 35 forks source link

Indexes are not being created for Memory Optimized tables on SQL Server #149

Open Daemach opened 3 years ago

Daemach commented 3 years ago

I'm trying to create indexes via both schema.create() and schema.alter() and neither are appearing in SQL Server. I don't even see attempts in fusion reactor. In this case I want to index every column in a view (long story), but nothing...

var columns = queryexecute("select top 1 * from vw_esg_data").columnlist();

schema.alter( "mars_in_custom_esg_data", function( table ) {
  columns.each((column)=>{
    table.index( [ column ], "idx_#column#_mars_in_custom_esg_data" );
  })
} );

I also tried this, but nothing there either (which method is better, btw?):

var columns = queryexecute("select top 1 * from vw_esg_data").columnlist();
columns.each((column)=>{
  schema.alter( "mars_in_custom_esg_data", function( table ) {
      table.index( [ column ], "idx_#column#_mars_in_custom_esg_data" );
  } );
})

And again, the indexes aren't showing up when creating new tables either. PK indexes for 'increments' columns are, but no custom indexes. And no error messages.

Daemach commented 3 years ago

I forgot the table.addConstraint() wrapper. However, when I added this, I got the error message mentioned in here: https://stackoverflow.com/questions/48864425/getting-error-the-operation-alter-table-add-index-is-not-supported-with-memory

Manually creating the indexes with the code offered in the only answer worked.

elpete commented 3 years ago

I've never heard of memory optimized tables. If it is the same end result, you can submit a PR that uses the CREATE INDEX syntax instead.