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

  • SEARCH
  • Home
  • 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 9060099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:08:10+00:00 2026-06-16T15:08:10+00:00

Here is my current table; CREATE TABLE `linkler` ( `link` varchar(256) NOT NULL, UNIQUE

  • 0

Here is my current table;

CREATE TABLE `linkler` (
  `link` varchar(256) NOT NULL,
  UNIQUE KEY `link` (`link`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

I will only use these 2 queries on the table, SELECT EXISTS (SELECT 1 FROM linkler WHERE link = ?) and INSERT INTO linkler (link) VALUES (?)

I don’t know much about indexing databases. Since I won’t be adding same thing twice, I thought marking it unique would be a good idea. Is there anything I can do to increase performance? For example, can I do something that rows are always sorted so that mysql can do binary search or something similiar?

  • 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-06-16T15:08:12+00:00Added an answer on June 16, 2026 at 3:08 pm

    Adding a unique index is perfect. Also, since you have a unique index, you don’t need to check for existence before you do an insert. You can simply use INSERT IGNORE to insert the row if it doesn’t exist (or ignore the error if it does):

    INSERT IGNORE INTO linkler (link) VALUES (?)
    

    Whether that will be faster than doing a SELECT/INSERT combination depends on how often you expect to have duplicates.

    ETA: If that is the only column in this table, you might want to make it a PRIMARY KEY instead of just a UNIQUE KEY although I don’t think it really matters much other than for clarity.

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

Sidebar

Related Questions

Here's our current table CREATE TABLE Visitor ( VisitorID bigint, DayPhone varchar(50), NightPhone varchar(50)
Here is my current SQLite table: CREATE TABLE formula (_id INTEGER PRIMARY KEY AUTOINCREMENT,suggest_text_1
here is my tables: DROP TABLE IF EXISTS `tbl_comments`; CREATE TABLE IF NOT EXISTS
CREATE TABLE `messages` ( `message_id` int(11) unsigned NOT NULL AUTO_INCREMENT, `message_project_id` int(7) unsigned NOT
Here is the table of interest when exported via phpMyAdmin: CREATE TABLE IF NOT
DROP TABLE IF EXISTS `media_publications`; CREATE TABLE `media_publications` ( `id` int(11) NOT NULL AUTO_INCREMENT,
Here is a table in MySQL 5.3.X+ db: CREATE TABLE members` ( `id` int(11)
Here's a snippet of my PHP that is creating the table: $sql = 'CREATE
I have a table with 17.6m rows 'CREATE TABLE `tmp_hist` ( `ti` int(11) DEFAULT
Here is an example of the current table I have: 1) Table name: TotalSales

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.