---
title: "biee的Ago的函数遇到的尴尬，一个不完美的解决方案"
author: "coolwolf911"
date: "2010-12-12T20:25:49Z"
tags: []
categories: ["数据库"]
slug: "biee-ago"
draft: false
lastmod: "2010-12-12T20:30:36Z"
id: 840238
url: "https://coolwolf911.iteye.com/blog/840238"
---

最近做OBIEE项目碰到Ago函数的性能问题，我们在事实表的时间字段加了索引，但是使用了ago函数在系统发出sql中where子句中居然没有时间条件，造成的我们的性能直线下降。为了解决这个问题，我们项目组的同事想n多方法进行尝试都没有有成功。
    今天下午我找了很多方法也没有找到完美的方案，但是发现一种可以实现方式，基本上可以解决了，我们的问题。

我们的解决方式是在模型的BUSSINESS层的LTS强行限制条件，使发出ago的sql也带了时间限制。
        步骤如下：
       1.制作一个提示器
            设置sesseion变量

      2. 在LTS 
          应用SESSION 变量
  
      3. hack JAVASCRIPT脚本globalfilterprompt.js 设置session
     
```javascrpt

    function GFPBuildFilter()
  {
...
   if (null != sSetVariable && sSetVariable != "")
   {
      XUISetAttributeString(tExpr, "setVariable", sSetVariable);
 // RoA - Set session variables
 alert(sSetVariable);
 alert(tValues[0]);
 if (null != tValues[0] && tValues[0] != "" ) {
  if (sSetVariable == "requestVariables['year_ini']") {
   jf_set_session_variable("YEAR_INI",tValues[0],"false");
  }
 }
   }
 return tExpr;
}
 
      
```

   方案基本觉得可行，继续测试一下效果。