Optimization – How does the MySQL optimizer calculate the join cost when indexed?

The theoretical standard formula is so

C (R1.R2) = C (R1) + T (R1) * C (R2) where

C (R1.R2) – costs for linking two relations (tables) R1 and R2

C (R1) – Reading Relation Costs R1

C (R2) – Cost of reading the relationship R2

T (R1) – total number of rows in R1

Apparently, this is the formula for nested loop join, if related for each row R1 and the loop checks to see if a matching row is related R2, But since MySQL creates an index for FK, does not it have to do NLJ right? What happens and how are the costs calculated?

mysql – Duplicate values ​​in a unique indexed column

I have a database table with a unique index idx_1(USER_ID, COURSE_ID)However, I have found a few entries with the same USER_ID and COURSE_ID (both not null). And the other columns of the duplicated lines are not the same. such as addtime (Standard timestamp) and updatetime (preset current timestamp when updating the current timestamp) of the duplicated 2 lines have a difference of 1 second:

SELECT * FROM user_course WHERE COURSE_ID='COURSEID1' AND USER_ID='USERID1';

----------------------------------------------------------------
UUID | COURSE_ID | USER_ID | ADDTIME         | UPDATETIME
----------------------------------------------------------------
abc1 |COURSEID1  | USERID1 | 2019-01-01 00:00| 2019-01-01 00:00


SELECT * FROM user_course WHERE UUID='abc1" OR UUID='abc2';

----------------------------------------------------------------
UUID | COURSE_ID | USER_ID | ADDTIME         | UPDATETIME
----------------------------------------------------------------
abc1 |COURSEID1  | USERID1 | 2019-01-01 00:00| 2019-01-01 00:00
----------------------------------------------------------------
abc2 |COURSEID1  | USERID1 | 2019-01-01 00:01| 2019-01-01 00:01

if I query the data with USER_ID and COURSE_ID Of one of the duplicated rows, only one row was returned. However, I can retrieve the rows with duplicate values ​​when I query the table with the primary key.

My question is: Is that a mistake of MySQL? and how can I avoid this mistake when working with MySQL?

Operating system: CentOS 6

MySQL: MySQL 5.6

Same Origin Policy – Prevents indexed theft of embedded services without API key

The service works in such a way that the user can embed content on his website that is provided by my servers. Usage is tracked in "Views", or how often the src Endpoint within the