English 中文(简体)
为什么它叫A Phantom Query?
原标题:Why Is It Called A Phantom Query?

I Am Confuse about Why it is Called as A Phantom Query. eg Assume these 3 Queries:-

学历 1

SELECT * FROM users
WHERE salary BETWEEN 10000 AND 300000;

返回记录2。

Query 2

INSERT INTO users VALUES ( 3,  Bob , 270000 );
COMMIT;

学历 1 again

SELECT * FROM users
WHERE salary BETWEEN 10000 AND 30000;

3份返回记录。

See See See 在我看来,这似乎是正常的。 我不理解他们为何被称作Phantom,所有交易都在不同的时间进行,因此我们总是得到最新数据。 最初有2个记录,后来在1个记录中插入。 我们再次获得最新数据,即3份记录。 因此,它为什么被称作Phantom Query?

最佳回答

在纯学术层面,交易应当根据交易开始时的数据,看到数据库的一贯状况。 它只能看自己的变化,也看不到其他东西。

只要交易1吨 t完成,就会把承诺的数据视为一种正文,因为它看到交易开始时不存在的行踪。

由于并非总是需要这种强有力的学术方法,因此采用了不同的孤立程度。 根据要求,开发商可以选择根据正在执行的业务规则需要哪些水平。

有时,你想要按正文读到:你使用<条码>,[......]孔塔普特普切特普特普特纳特普特纳特普特普特(电话:+)隔离等级(大多数房舍管理处都缺),有时不想要他们——然后使用<条码> SERIZABLE/密码>。

问题回答

Phantom reads occur if range locks are not well set on the transaction. What will happen here is exactly what you wrote - first select will return 2 rows, while the second select will return 3 rows.
Phantom read by definition means that two identical queries are executed, and the collection of rows returned by the second query is different from the first. If the correct isolation was applied, the same set of rows should be returned both times.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签