小编sou*_*zin的帖子

为什么从大表查询COUNT()比SUM()快得多

我有一个带有下表的数据仓库:

主要

约800万条记录

CREATE TABLE `main` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`cid` mediumint(8) unsigned DEFAULT NULL, //This is the customer id
`iid` mediumint(8) unsigned DEFAULT NULL, //This is the item id
`pid` tinyint(3) unsigned DEFAULT NULL, //This is the period id
`qty` double DEFAULT NULL,
`sales` double DEFAULT NULL,
`gm` double DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `idx_pci` (`pid`,`cid`,`iid`) USING HASH,
KEY `idx_pic` (`pid`,`iid`,`cid`) USING HASH
) ENGINE=InnoDB AUTO_INCREMENT=7978349 DEFAULT CHARSET=latin1
Run Code Online (Sandbox Code Playgroud)

该表大约有50条记录,并且具有以下字段

  • ID

顾客

大约有23,000条记录,以下文件 …

mysql sql performance

2
推荐指数
1
解决办法
1960
查看次数

控制台关闭时不会调用终结器

在打开Windows窗体和控制台的C#应用​​程序中,为什么每当关闭From时调用Finalizer,而不是在控制台关闭时调用?即使从控制台关闭应用程序,有没有办法调用Finalizer?

我在创建一个在Construction上创建文件的类并在Dispose/Finalize上删除文件时注意到了这一点.关闭表单时,它按预期工作,但正在创建文件但关闭控制台时未删除.

编辑

我必须对这些条款感到困惑.这是我的临时文件代码:

class TemporaryFile : IDisposable {
    private String _FullPath;

    public String FullPath {
        get {
            return _FullPath;
        }
        private set {
            _FullPath = value;
        }
    }

    public TemporaryFile() {
        FullPath = NewTemporaryFilePath();
    }

    ~TemporaryFile() {
        Dispose(false);
    }

    private String NewTemporaryFilePath() {
        const int TRY_TIMES = 5; // --- try 5 times to create a file

        FileStream tempFile = null;
        String tempPath = Path.GetTempPath();
        String tempName = Path.GetTempFileName();

        String fullFilePath = Path.Combine(tempPath, tempName);
            try {
                tempFile = System.IO.File.Create(fullFilePath); …
Run Code Online (Sandbox Code Playgroud)

c#

2
推荐指数
1
解决办法
1118
查看次数

未捕获的ReferenceError.在jQuery事件处理程序中找不到原型函数

按下提交按钮时出现以下错误:

Uncaught ReferenceError: addText is not defined 
Run Code Online (Sandbox Code Playgroud)
  • 为什么'click'处理函数找不到类原型函数'addText'?

  • 我该怎么做才能解决这个问题?

  • 如果这是处理事件的坏方法?(我来自java背景,我对使用面向对象的javascript的最佳实践不太了解)

这是代码:

<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="js/jquery-1.9.1.js"></script>
    <script>
        //Class ctor
        function MyClass() {
            this.msg = "Hello World!";
        }
        //This method appends text to the given doc element
        MyClass.prototype.addText = function(doc) {
            $(doc).append('<br/>'+this.msg);
        };
       /*
        * This method adds a 'click' listener to the given element which 
        * calls the 'addText' method on its parent.
        */
        MyClass.prototype.listenToButton = function(btn) {
            $(btn).bind({
                click: function(event) {
                    addText($(this).parent());
                }
            });
        };

        $(document).ready(function() …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

1
推荐指数
1
解决办法
1995
查看次数

标签 统计

c# ×1

html ×1

javascript ×1

jquery ×1

mysql ×1

performance ×1

sql ×1