首页 \ 问答 \ MYSQL innodb还是myisam?(MYSQL innodb or myisam? Which one is best for this case?)

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
更新时间:2023-05-09 14:05

最满意答案

看一下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 ...
  • 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_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"))); 然后,您应该能够使用构面格式化为字符串。 编辑:完整 ...
  • 时间戳记在自“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 ...
  • 我不知道你想在这里实现什么,但是如果你改变了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 ...
  • 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来操作日期时间: ...
  • 如果要在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 ...
  • 你可以使用你的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()函数< ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)