To improve SQL-queries in DDL

后端 未结 1 931
情话喂你
情话喂你 2020-12-22 01:47

Improvements done

  1. nvarchar(5000) -> nvarchar(4000) BUT no nvarchar in PostgreSQL => TEXT
  2. memory limits to some variables
  3. the
相关标签:
1条回答
  • 2020-12-22 02:16

    When you use varchar(4000) and so, is 4000 actually a conceptual maximum of how long the string can be there? Or did you just pick something "big enough for everything"? If the second, just use the text datatype. It will be just as fast (actually, a tiny bit faster, but you will not likely be able to measure that).

    sent_time looks like it should be a timestamptz. Don't store date/time in a varchar.

    auto_increment is not in postgres, use a serial column.

    You have a circular reference between Tags and Questions, which I'm sure you didn't intend. And your check constraint on Questions.question_id appears checks user_id - too much copy/paste I bet.

    Finally, don't use mixed case identifiers. Do everything lowercase, so you don't have to quote them. For instance, use lowercase for column and table names.

    0 讨论(0)
提交回复
热议问题