mysql時間區間效率_對于sql中使用to_timestamp判斷時間區間和不使用的效率對比及結論...

關于日期函數TO_TIMESTAMP

拓展:

date類型是Oracle常用的日期型變量,時間間隔是秒。兩個日期型相減得到是兩個時間的間隔,注意單位是“天”。

timestamp是DATE類型的擴展,可以精確到小數秒(fractional_seconds_precision),可以是?0to9,缺省是6。兩個timestamp相減的話,不能直接的得到天數,而是得到,多少天,多少小時,多少秒等。

使用TO_TIMESTAMP函數:

select

distinct hiui.salesman_id as salesmanId,

hui.user_name as salesmanName,

hui.user_phone as salesmanPhone,

hiui.class_id as classId,

hiui.department_id as departmentId,

get_affiliaction_name(hiui.class_id, hiui.department_id) as affiliactionName

from hz_invited_user_info as hiui

inner join hz_user_info as hui on hui.user_id = hiui.salesman_id

where

to_timestamp('2018-01-01 00:00:00','yyyy-mm-dd hh24:mi:ss') <= hiui.create_time

and to_timestamp('2019-05-28 00:00:00','yyyy-mm-dd hh24:mi:ss') >= hiui.create_time

時間: 0.949s? ? ? ? ? ??時間: 0.973s? ? ? ? ? ? ? ?時間: 0.783s

不使用:

select

distinct hiui.salesman_id as salesmanId,

hui.user_name as salesmanName,

hui.user_phone as salesmanPhone,

hiui.class_id as classId,

hiui.department_id as departmentId,

get_affiliaction_name(hiui.class_id, hiui.department_id) as affiliactionName

from hz_invited_user_info as hiui

inner join hz_user_info as hui on hui.user_id = hiui.salesman_id

where

'2018-01-01 00:00:00' <= hiui.create_time

and '2019-05-26 00:00:00' >= hiui.create_time

時間: 0.79s? ? ? ? ? ? ?時間: 0.743s? ? ? ? ? ? ? ? ? ?時間: 0.747s

兩者分別執行了3次,發現不使用效率更高,因為在sql執行的時候,會自動把時間字符串轉換成時間戳。但是使用效率也區別不是很明顯,可能是小數據的原因。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/392520.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392520.shtml
英文地址,請注明出處:http://en.pswp.cn/news/392520.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

ajax 賦值return

ajax 獲得結果后賦值無法成功&#xff0c; function grades(num){ var name"";   $.ajax({    type:"get",     url:"",     async:true,     success:function(result){     var grades result.grades;     …

JavaScript(ES6)傳播算子和rest參數簡介

by Joanna Gaudyn喬安娜高登(Joanna Gaudyn) JavaScript(ES6)傳播算子和rest參數簡介 (An intro to the spread operator and rest parameter in JavaScript (ES6)) 擴展運算符和rest參數都被寫為三個連續的點(…)。 他們還有其他共同點嗎&#xff1f; (Both the spread opera…

python爬蟲消費者與生產者_Condition版生產者與消費者模式

概述&#xff1a;在人工智能來臨的今天&#xff0c;數據顯得格外重要。在互聯網的浩瀚大海洋中&#xff0c;隱藏著無窮的數據和信息。因此學習網絡爬蟲是在今天立足的一項必備技能。本路線專門針對想要從事Python網絡爬蟲的同學而準備的&#xff0c;并且是嚴格按照企業的標準定…

【Python包】安裝teradatasql提示找不到pycryptodome模塊錯誤(pycrypto,pycryptodome和crypto加密庫)...

1.問題描述 安裝teradatasql時&#xff0c;出現錯誤Could not find a version that satisfies the requirement pycryptodome&#xff0c;具體如下&#xff1a; 2.解決方法 查看Python第三方庫目錄$PYTHON_HOME/lib/python3.6/site-packages目錄下沒有pycryptodome目錄&#xf…

leetcode 860. 檸檬水找零(貪心算法)

在檸檬水攤上&#xff0c;每一杯檸檬水的售價為 5 美元。 顧客排隊購買你的產品&#xff0c;&#xff08;按賬單 bills 支付的順序&#xff09;一次購買一杯。 每位顧客只買一杯檸檬水&#xff0c;然后向你付 5 美元、10 美元或 20 美元。你必須給每個顧客正確找零&#xff0…

簡述yolo1-yolo3_使用YOLO框架進行對象檢測的綜合指南-第二部分

簡述yolo1-yolo3In the last part, we understood what YOLO is and how it works. In this section, let us understand how to apply it using pre-trained weights and obtaining the results. This article is greatly inspired by Andrew Ng’s Deep Learning Specializat…

ubuntu配置JDK環境

>>>cd /usr/lib >>>mkdir java >>>cd java ###這里的參數表示接收他們的協議 >>>wget --no-check-certificate --no-cookies --header "Cookie: oraclelicenseaccept-securebackup-cookie" http://download.oracle.com/otn-pub/…

java cxf 調用wcf接口_JAVA 調用 WCF 服務流程

1. 將 WCF 服務發布到 Windows 服務(或者 IIS)此步驟的目的是為 WCF 服務搭建服務器&#xff0c;從而使服務相關的 Web Services 可以被 JAVA 客戶端程序調用&#xff0c;具體步驟參考如下&#xff1a;(1) 發布到 Windows 服務(2) 發布到 IIS注&#xff1a;如果是將 WCF 服務…

react第三方組件庫_如何自定義您的第三方React組件

react第三方組件庫by Jacob Goh雅各布高 如何自定義您的第三方React組件 (How to customize your third party React components) Component libraries make our lives easier.組件庫使我們的生活更輕松。 But as developers, you might often find yourselves in situations…

gcp devops_將GCP AI平臺筆記本用作可重現的數據科學環境

gcp devopsBy: Edward Krueger and Douglas Franklin.作者&#xff1a; 愛德華克魯格 ( Edward Krueger)和道格拉斯富蘭克林 ( Douglas Franklin) 。 In this article, we will cover how to set up a cloud computing instance to run Python with or without Jupyter Notebo…

迅為工業級iMX6Q開發板全新升級兼容PLUS版本|四核商業級|工業級|雙核商業級...

軟硬件全面升級 1. 新增Yocto項目的支持 增加opencv等軟件功能 2. 新近推出i.MX6增強版本核心板&#xff08;PLUS&#xff09; -性能更強 四種核心板全兼容 四核商業級2G/16G&#xff1b;雙核商業級1G/8G &#xff1b;四核工業級1G/8G &#xff1b;四核增強版(PLUS) 3. 豪華配…

flume 中的 hdfs sink round 和roll

http://blog.csdn.net/kntao/article/details/49278239 http://flume.apache.org/FlumeUserGuide.html#exec-source 默認的是是SequenceFile所以數據存在hdfs上通過命令查看的時候會是亂碼,如果此時需要修改filetype和writeFormat來修改 hdfs.fileTypeSequenceFileFile format:…

leetcode 649. Dota2 參議院(貪心算法)

Dota2 的世界里有兩個陣營&#xff1a;Radiant(天輝)和 Dire(夜魘) Dota2 參議院由來自兩派的參議員組成。現在參議院希望對一個 Dota2 游戲里的改變作出決定。他們以一個基于輪為過程的投票進行。在每一輪中&#xff0c;每一位參議員都可以行使兩項權利中的一項&#xff1a; …

電力現貨市場現貨需求_現貨與情緒:現貨銅市場中的自然語言處理與情緒評分

電力現貨市場現貨需求Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works with…

PHP學習系列(1)——字符串處理函數(2)

6、chunk_split() 函數把字符串分割為一連串更小的部分。本函數不改變原始字符串。 語法&#xff1a;chunk_split(string,length,end) 參數&#xff1a; string——必需。規定要分割的字符串。 length——可選。一個數字&#xff0c;定義字符串塊的長度。 end——可選。字符串值…

java做主成分分析_主成分分析PCA

PCA(Principal Component Analysis)&#xff0c;即主成分分析&#xff0c;一種常用于數據降維分析的方法。要理解PCA的原理&#xff0c;首先需要理解矩陣變換的意義。矩陣變換&#xff0c;有兩種意義&#xff1a;1&#xff0c;在當前坐標系下的向量&#xff0c;經過矩陣M變換后…

個人學習進度(第十六周)

轉載于:https://www.cnblogs.com/lhj1017/p/7011993.html

什么叫靜態構建版本號碼_為什么要使用GatsbyJS構建靜態網站

什么叫靜態構建版本號碼by Ajay NS由Ajay NS 為什么要使用GatsbyJS構建靜態網站 (Why you should use GatsbyJS to build static sites) Gatsby has been growing over time, and I’m glad to see it in use by a huge number of sites like marketing sites, blogs, and gen…

leetcode 217. 存在重復元素

給定一個整數數組&#xff0c;判斷是否存在重復元素。 如果任意一值在數組中出現至少兩次&#xff0c;函數返回 true 。如果數組中每個元素都不相同&#xff0c;則返回 false 。 示例 1: 輸入: [1,2,3,1] 輸出: true 代碼 class Solution {public boolean containsDuplica…

C#正則表達式提取HTML中IMG標簽的URL地址 .

/// <summary> /// 取得HTML中所有圖片的 URL。 /// </summary> /// <param name"sHtmlText">HTML代碼</param> /// <returns>圖片的URL列表</returns> public static string[] GetHtmlImageUrlList(string sHtmlText) { // 定…