I was a MySQL user. Now I'm migrating to SQL Server. But I have a problem. I can not find any way for specifiying the kind of index a table has. In MySQL I could easily say to build a BTree Index or Hash Index. How can I do that here?
The main problem is that I have two tables. one of them (named "posts") has a foreign key to the other (named "users") which has a primary key constraint on "id". In my java program for inserting posts I have to check whether the user of this post has been inserted or not and if not, insert it (I can not insert all users first!).
This code was inserting about 1000 posts in each 10 seconds in MySQL. But In SQL Server the search part takes too much time and 1000 posts takes more than 1 minute.
This is the slow SQL query:
select * from users u where u.id = "UserName"
This is the user table:
CREATE TABLE [dbo].[users](
[id] [varchar](50) NOT NULL,
[type] [char](1) NULL,
[name] [nvarchar](150) NULL,
[reserved] [char](8) NULL,
[description] [nvarchar](4000) NULL,
[text] [ntext] NULL,
CONSTRAINT [PK__users__3213E83F00551192] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
What's the problem?
Thank you.