MYSQL innodb还是myisam?(MYSQL innodb or myisam? Which one is best for this case?)
我真的迷失在我应该为我的桌子挑选哪种类型的数据库引擎。
+-----------------------+ | id | userid | content | +-----------------------+
想象一下这张桌子。 userid正在保存存储在另一个表中的用户ID。 此外,其他一些表正在使用此表的id字段。 因此,我认为将id设置为主键,将userid设置为外键将加速连接过程。 但是,如果我选择我的表作为InnoDB来设置外键,那么我就无法对内容进行FULLTEXT搜索(这是一个TEXT字段)。
所以基本上,如果我切换回MyISAM使用FULLTEXT搜索,加入时会有问题吗,比如3-4个数十亿行的表?
PS:如果有另一种可行的方法来创建表来处理连接和全文,请告诉我,我也可以更改表结构。
I'm really lost on which type of database engine should I pick for my table.
+-----------------------+ | id | userid | content | +-----------------------+
Imagine this table. userid is holding user ids which are stored in another table. Also, some other tables are using the id field of this table. Therefore, I thought that setting id as primary key and userid as a foreign key would speed up the join processes. However, if I select my table as InnoDB to set foreign keys, then I cannot conduct a FULLTEXT search on content (which is a TEXT field).
So basically, if I switch back to MyISAM to use the FULLTEXT searches, will I have problems when joining, say, 3-4 tables of hundreds of millions of rows?
PS: If there is another liable way to create tables to handle both joins and fulltexts, please tell me so, I can change the tables structure as well.
原文:https://stackoverflow.com/questions/7820691
最满意答案
看一下boost :: local_time :: local_date_time类。 您可以指定时区并使用本地微秒钟来初始化它
boost::local_time::local_date_time my_ldt(boost::local_time::local_microsec_clock::local_time(new boost::local_time::posix_time_zone("EST-5EDT,M4.1.0,M10.5.0")));
然后,您应该能够使用构面格式化为字符串。
编辑:完整示例:
#include <iostream> #include <iomanip> #include <string> #include <sstream> #include <boost/date_time/local_time/local_time.hpp> int main(void) { boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); boost::posix_time::ptime utc = boost::posix_time::second_clock::universal_time(); boost::posix_time::time_duration tz_offset = (now - utc); std::stringstream ss; boost::local_time::local_time_facet* output_facet = new boost::local_time::local_time_facet(); ss.imbue(std::locale(std::locale::classic(), output_facet)); output_facet->format("%H:%M:%S"); ss.str(""); ss << tz_offset; boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone(ss.str().c_str())); boost::local_time::local_date_time ldt = boost::local_time::local_microsec_clock::local_time(zone); boost::local_time::local_time_facet* output_facet = new boost::local_time::local_time_facet(); ss.imbue(std::locale(std::locale::classic(), output_facet)); output_facet->format("%Y-%m-%d %H:%M:%S%f%Q"); ss.str(""); ss << ldt; std::cout << ss.str() << std::endl; // "2004-02-29 12:34:56.000789-05:00" std::cout << "Press return to exit" << std::endl; std::string wait_for_line; std::getline(std::cin, wait_for_line); return (0); }
Have a look at the boost::local_time::local_date_time class. You can specify a time zone and use the local microsecond clock to initialize it like
boost::local_time::local_date_time my_ldt(boost::local_time::local_microsec_clock::local_time(new boost::local_time::posix_time_zone("EST-5EDT,M4.1.0,M10.5.0")));
You should then be able to use the facets to format to a string.
Edit: Full example:
#include <iostream> #include <iomanip> #include <string> #include <sstream> #include <boost/date_time/local_time/local_time.hpp> int main(void) { boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); boost::posix_time::ptime utc = boost::posix_time::second_clock::universal_time(); boost::posix_time::time_duration tz_offset = (now - utc); std::stringstream ss; boost::local_time::local_time_facet* output_facet = new boost::local_time::local_time_facet(); ss.imbue(std::locale(std::locale::classic(), output_facet)); output_facet->format("%H:%M:%S"); ss.str(""); ss << tz_offset; boost::local_time::time_zone_ptr zone(new boost::local_time::posix_time_zone(ss.str().c_str())); boost::local_time::local_date_time ldt = boost::local_time::local_microsec_clock::local_time(zone); boost::local_time::local_time_facet* output_facet = new boost::local_time::local_time_facet(); ss.imbue(std::locale(std::locale::classic(), output_facet)); output_facet->format("%Y-%m-%d %H:%M:%S%f%Q"); ss.str(""); ss << ldt; std::cout << ss.str() << std::endl; // "2004-02-29 12:34:56.000789-05:00" std::cout << "Press return to exit" << std::endl; std::string wait_for_line; std::getline(std::cin, wait_for_line); return (0); }
相关问答
更多-
问题是接收器中的区域设置不用于日志消息字符串格式。 它不能使用,因为可能有多个接收器,并且选择不明确。 该区域设置用于日志记录格式化,这是针对每个接收器单独执行的。 日志消息字符串由为每条日志消息初始化的流组成,因此您不能以自定义区域设置的方式将其填充,以保持用于多个记录的区域设置。 在使用Boost.Log之前,您可以做的是将自定义区域设置设置为应用程序初始化代码中的全局区域设置。 void main(void) { pt::time_facet *facet = new boost::posix ...
-
awk格式化输出并添加日期时间戳[重复](Awk formatting of the output and adding a date time stamp [duplicate])[2023-07-29]
gawk ' BEGIN { OFS="\t" date = strftime("%Y-%m-%d", systime()) out = "File3.txt" err = "File4.txt" } NR==FNR && NF {line[$1]=$0; next} function print_77_99() { if (key in line) print "77", line[key] > out else { ... -
时间戳问题(Time Stamp Question)[2022-07-05]
数字值是一个time_t ,你需要将它转换为local或greenmich时间,分别为localtime()或gmtime() ,然后你可以使用strftime()以你选择的格式打印。 这是一个快速而完整的例子: edd@max:/tmp$ cat timeformat.c #include#include #include int main(void) { time_t tt = 3.44063E+08; struct t ... -
看一下boost :: local_time :: local_date_time类。 您可以指定时区并使用本地微秒钟来初始化它 boost::local_time::local_date_time my_ldt(boost::local_time::local_microsec_clock::local_time(new boost::local_time::posix_time_zone("EST-5EDT,M4.1.0,M10.5.0"))); 然后,您应该能够使用构面格式化为字符串。 编辑:完整 ...
-
以长格式(YYYYMMDDhhmmss.mmmuuun)格式的UTC时间戳(UTC time stamp in long form (YYYYMMDDhhmmss.mmmuuun) formatting)[2022-06-18]
时间戳记在自“Epoch”(1970年1月1日)格式以来的毫秒数中。 请参阅https://www.epochconverter.com/ 日期2018-12-07 09:17:55.000将由/ Date(1544174275000)/表示。 The timestamp is in "milliseconds since the Epoch" (1 Jan 1970) format. See https://www.epochconverter.com/ The date 2018-12-07 09:17 ... -
Unix时间戳格式化(Unix time stamp formatting)[2022-04-11]
我不知道你想在这里实现什么,但是如果你改变了dmy h:i:sa to dmY h:i:sa ,它会给你正确的日期。 date_default_timezone_set('Europe/London'); $todaysdate = date('d-m-Y h:i:s a', time()); $todaysdatestring = strtotime($todaysdate); 但是如果你想获得当前的时间戳,为什么不简单地使用time() 。 I don't know what are you tryi ... -
时间戳转换为秒(Time stamp conversion to seconds)[2022-01-18]
timestr的文档提到它期望dateenum返回的格式: TS = TIMESTR(D)将序列日期数字( 由DATENUM返回 )D转换为格式为HH:MM:SS.SSSS的字符串TS。 dateenum返回自0000年1月0日以来的天数: datenum函数创建一个数值数组,表示每个时间点为0000年1月0日的天数 。 所以,如果你的抵消是7小时,那么差值应该是7/24,这确实是0.2917,正如L. Scott Johnson所建议的那样。 从2014b开始,您可以使用datetime来操作日期时间: ... -
mysql time_stamp格式(mysql time_stamp format)[2024-01-12]
如果要在SQL查询中进行格式化,可以在MySQL中使用DATE_FORMAT()函数 。 SELECT DATE_FORMAT(columnName, '%b %D %Y') AS my_date FROM tableName; 在PHP中格式化日期,您将需要在PHP中使用date()函数 。 $my_date = date('M jS Y', $timestamp); If you want to do the formatting in an SQL query, you can use the D ... -
比较时间戳(Comparing Time Stamp)[2022-02-22]
你可以使用你的get_the_time, $time2 = get_the_time( __( 'd-m-Y H:i:s', 'woocommerce' ), $order->ID ); 然后, $time = current_time( 'timestamp' ); $time1 = date('d-m-Y H:i:s', $time); $date1 = new DateTime($time1); $date2 = new DateTime($time2); $interval = $date1-> ... -
对所述问题的简单回答是“如何将TSC频率转换为微秒或毫秒?” 是:你没有。 TSC(时间戳计数器)的时钟频率实际上是根据硬件而变化的,并且在运行期间可能会有所不同。 要测量实时,请在Linux中使用clock_gettime(CLOCK_REALTIME)或clock_gettime(CLOCK_MONOTONIC) 。 正如Peter Cordes在评论中提到的(2018年8月),在大多数当前的x86-64体系结构中,时间戳计数器(由
声明的RDTSC指令和__rdtsc()函数< ...