Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:32:26+00:00 2026-05-13T16:32:26+00:00

Table1 ———— ID IdColumn1 Idcolumn2 Table2 ———— ID IdColumn IdPair Both of them contains

  • 0
Table1
------------
ID
IdColumn1
Idcolumn2

Table2
------------
ID
IdColumn
IdPair

Both of them contains the same data.

Table1 have both column populated, Table2 have those columns stored on two rows.

So, if Table1 contains n rows, Table2 will have 2 * n rows

Wich query is faster ?

select * from Table1 
where IdColumn1 = x or IdColumn2 = x

or

select * from Table2 where IdColumn = x

I already choose Table2 scheme and I have over 400.000 rows until now and over 1000 unique visitors per day. Every day is added over 2000 rows in this database. My website keep growing very fast.

Don’t ask me why there are so many rows, they play games in online competitions and those rows are matches between players.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:32:27+00:00Added an answer on May 13, 2026 at 4:32 pm

    I’d choose Table2.

    With the Table1 schema you need two indexes at least, one on IdColumn1 and one on IdColumn2 and you can query it efficiently using:

    select * from Table1 where IdColumn1 = x
    union all 
    select * from Table1 where IdColumn2 = x;
    

    But at least one of the indexes is non-clustered and you’ll have a lot of logic juggling to identify all items related to a player, since they can be on either IdColumn1 or on IdColumn2. And just think at the mess a 3 way game will bring in the future (3 players, add IdColumn3…).

    Table2 is better, as it has a clear purpose: stores all the games a player had participated in, clustered by the player Id. It can be interogated more simply, it can be structured more simply, and can be extended to more players per game later on.

    Not sure what PairId is though. Your data model is a typical many-to-many relation, just replace ‘Player’ with ‘Student’ and ‘Game’ with ‘Course’ and you’ll see that you ahve exactly the canonical Data Modeling 101 course structure of Students-Course (in your case it so happens that a game (=course) can have exactly 2 players (=students), but thet’s a detail. You’re still talking about a typical 3 table relationship (1 for games, 1 for players, one for player-to-game participation).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table1 has data to be imported into Table2. Table1 contains only varchar fields, but
I have two tables table1 , table2 . Both have a one to one
I have records in table1, if the records exist, it must copy into table2.
I have Table1 and Table2 related on Table1.ID. There can be zero or more
table1 has column CITY and COUNTRY. table2 has column CITY. how do i delete
I have table1 and table2 in a class.. public DataTable sampletable (DataTable table1,DataTable table2)
Using Sql Server 2005 Table1 ID Value ABC001 BCE002 ... I have search column,
I have 3 tables: table1:table1_col1, table1_col2,table1_col3 table2 : table1_col1, table2_col2,table2_col3 table3 : table1_col1, table3_col2,table3_col3
Suppose Table1 contains column orderid (not a key, although it's NOT NULL and unique).
I have two tables: Table1: id attr1 fk1(Table2) fk2(Table2) Table2: id name I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.