查看 MySQL 临时表 - 不在会话中

发布于 2024-12-18 12:41:34 字数 146 浏览 4 评论 0原文

我当前正在运行一个脚本,但没想到会花费这么长时间来运行,该脚本正在修改临时表。

我知道临时表仅存在于当前会话中,但是无论如何可以从会话外部查看它们保存的数据吗?

原因是我想知道我的脚本将继续运行多长时间,如果我可以看到临时数据,那么我就能弄清楚。

I currently have a script running and didn't think it would take so long to run, the script is modifying a temporary table.

I know that temporary tables only exist for the current session, but is there anyway to see the data they hold from outside the session?

Reason is that I want to know how long my script is going to keep running for, if I could see the temporary data then I'd be able to figure it out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

記憶穿過時間隧道 2024-12-25 12:41:34

恐怕没有简单的方法可以做到这一点。

临时表将存储在 mysqld 指定的临时目录中(通常为 /tmp),您将看到一组类似于以下内容的表:

-rw-rw---- 1 mysql mysql     8724 Nov 29 18:09 #sqldba_5fa70c_12f1.frm
-rw-rw---- 1 mysql mysql   188408 Nov 29 18:09 #sqldba_5fa70c_12f1.MYD
-rw-rw---- 1 mysql mysql     1024 Nov 29 18:09 #sqldba_5fa70c_12f1.MYI

这是一组正常的 MyISAM 表,定义(按上面的顺序)结构、数据和索引。

这非常糟糕,但我怀疑您可以将这些表复制到您的 test 模式中,对表进行修复,然后查看其内容。

如果您可以通过临时表的大小来衡量进程,那么这很可能是分析正在发生的情况的更简单的方法。

There's no easy way of doing this I'm afraid.

Temporary tables will be stored in your mysqld's designated temp directory (usually /tmp) and you'll see a set of tables something like:

-rw-rw---- 1 mysql mysql     8724 Nov 29 18:09 #sqldba_5fa70c_12f1.frm
-rw-rw---- 1 mysql mysql   188408 Nov 29 18:09 #sqldba_5fa70c_12f1.MYD
-rw-rw---- 1 mysql mysql     1024 Nov 29 18:09 #sqldba_5fa70c_12f1.MYI

That's a normal set of MyISAM tables defining (in order above) structure, data and index.

This is horribly hacky but I suspect you could copy these tables out into say your test schema, run a repair on the table and then view it's contents.

If you can gauge the process by the size of the temp table then that could well be a simpler way of analysing what's going on.

叶落知秋 2024-12-25 12:41:34

不可能,但可以(但是),
日志里程碑(消息、完成百分比、已处理的行数)
写入临时文件,并使用 tail -f log_file 进行监控

Is not possible, you can (however),
log milestone (message, % of completion, number rows processed)
into a temporary file, and use the tail -f log_file to monitor

暖风昔人 2024-12-25 12:41:34

在 MySQL 5.7 中,添加了新的 INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO: http://dev.mysql.com/doc/refman/5.7/en/innodb-information-schema-temp-table-info.html

否则,Percona XtraDB 已经拥有此功能一段时间了:http://venublog。 com/2010/02/03/show-temporary-tables/

In MySQL 5.7 a new INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO has been added: http://dev.mysql.com/doc/refman/5.7/en/innodb-information-schema-temp-table-info.html.

Otherwise Percona XtraDB has had this feature for a little while: http://venublog.com/2010/02/03/show-temporary-tables/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文